Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -97,22 +97,17 @@ def infer(prompt, negative="low_quality", style_name=None, guidance_scale=None):
|
|
| 97 |
return image_b64
|
| 98 |
|
| 99 |
|
| 100 |
-
@app.
|
| 101 |
-
|
| 102 |
-
if
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
style_name = data['style_name']
|
| 108 |
-
guidance_scale = data['guidance_scale']
|
| 109 |
-
|
| 110 |
-
image_urls = infer(prompt, style_name=style_name, guidance_scale=guidance_scale)
|
| 111 |
|
| 112 |
# Convert the first generated image to base64
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
return {"image_base64": image_b64}
|
| 116 |
else:
|
| 117 |
raise HTTPException(status_code=400, detail="Missing required parameters")
|
| 118 |
else:
|
|
|
|
| 97 |
return image_b64
|
| 98 |
|
| 99 |
|
| 100 |
+
@app.post("/")
|
| 101 |
+
def generate_image(data: dict):
|
| 102 |
+
if 'prompt' in data and 'style_name' in data and 'guidance_scale' in data:
|
| 103 |
+
prompt = data['prompt']
|
| 104 |
+
style_name = data['style_name']
|
| 105 |
+
guidance_scale = data['guidance_scale']]
|
| 106 |
+
image_urls = infer(prompt, style_name=style_name, guidance_scale=guidance_scale)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
# Convert the first generated image to base64
|
| 109 |
+
image_b64 = image_urls[0].split(",")[1]
|
| 110 |
+
return {"image_base64": image_b64}
|
|
|
|
| 111 |
else:
|
| 112 |
raise HTTPException(status_code=400, detail="Missing required parameters")
|
| 113 |
else:
|