Metadata-Version: 2.4
Name: senn-bandgap
Version: 0.1.0
Summary: SENN bandgap predictor for perovskite compositions
Author: Jufeng Han
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: torch>=2.0
Requires-Dist: numpy>=1.23
Provides-Extra: web
Requires-Dist: fastapi>=0.110; extra == "web"
Requires-Dist: uvicorn[standard]>=0.27; extra == "web"
Requires-Dist: streamlit>=1.30; extra == "web"
Provides-Extra: dev
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

# SENN Bandgap Predictor

This repository packages a SENN perovskite bandgap model as:

1. a Python package,
2. a command-line tool,
3. a FastAPI HTTP API,
4. a Streamlit web app.

## Input convention

The model input order is:

```text
[MA, FA, Cs, Br, Cl, I]
```

Internally:

- `site_a = [MA, FA, Cs]`
- `site_x = [Br, Cl, I]`

## Local installation

```bash
cd senn_bandgap_deploy_template
pip install -e .
```

## Python usage

```python
from senn_bandgap import BandgapPredictor

predictor = BandgapPredictor()
y = predictor.predict([[0.0, 1.0, 0.0, 0.0, 0.0, 1.0]])
print(y[0])
```

## CLI usage

```bash
senn-bandgap --MA 0 --FA 1 --Cs 0 --Br 0 --Cl 0 --I 1
```

## Start FastAPI server

```bash
uvicorn api_fastapi:app --host 0.0.0.0 --port 8000
```

Open:

```text
http://127.0.0.1:8000/docs
```

Example request:

```bash
curl -X POST "http://127.0.0.1:8000/predict"   -H "Content-Type: application/json"   -d '{"MA":0,"FA":1,"Cs":0,"Br":0,"Cl":0,"I":1}'
```

## Start Streamlit app

```bash
streamlit run app_streamlit.py
```

## Deployment options

### Streamlit Community Cloud

Push this repository to GitHub, then select `app_streamlit.py` as the entrypoint.

### Hugging Face Spaces

Create a Space and use Gradio or Streamlit as the SDK. For Streamlit, keep `app_streamlit.py` and `requirements.txt`.

### Docker + FastAPI

```bash
docker build -t senn-bandgap .
docker run -p 8000:8000 senn-bandgap
```

## Important note

If the original training used input normalization, target scaling, or composition preprocessing, you must reproduce exactly the same preprocessing during inference. Otherwise the API will run, but the predicted bandgap values may be numerically inconsistent with training.
