SyntheticVis-Umut commited on
Commit ·
6feb63c
1
Parent(s): 3e6a450
Fix environment variable name from MODEL_ID to MODEL for Hugging Face Spaces
Browse files
app.py
CHANGED
|
@@ -9,9 +9,15 @@ app = FastAPI(title="ImageGen API")
|
|
| 9 |
|
| 10 |
# Choose a model that supports text->image via Inference API.
|
| 11 |
# Using a model that works well with InferenceClient
|
| 12 |
-
MODEL_ID = os.getenv("
|
| 13 |
HF_TOKEN = os.getenv("HF_TOKEN") # set in Space Secrets
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
class GenReq(BaseModel):
|
| 17 |
prompt: str
|
|
|
|
| 9 |
|
| 10 |
# Choose a model that supports text->image via Inference API.
|
| 11 |
# Using a model that works well with InferenceClient
|
| 12 |
+
MODEL_ID = os.getenv("MODEL", "stabilityai/stable-diffusion-xl-base-1.0")
|
| 13 |
HF_TOKEN = os.getenv("HF_TOKEN") # set in Space Secrets
|
| 14 |
+
|
| 15 |
+
# Initialize client with or without token
|
| 16 |
+
if HF_TOKEN:
|
| 17 |
+
client = InferenceClient(model=MODEL_ID, token=HF_TOKEN)
|
| 18 |
+
else:
|
| 19 |
+
# Use public inference API (may have rate limits)
|
| 20 |
+
client = InferenceClient(model=MODEL_ID)
|
| 21 |
|
| 22 |
class GenReq(BaseModel):
|
| 23 |
prompt: str
|