Update app.py
Browse files
app.py
CHANGED
@@ -48,27 +48,29 @@ def generate_text(prompt, temperature=0.9, max_new_tokens=512, top_p=0.95, repet
|
|
48 |
def generate_image(prompt):
|
49 |
try:
|
50 |
result = image_client.predict(
|
51 |
-
prompt
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
isImg2Img=False,
|
67 |
-
img_path=None,
|
68 |
-
img2img_strength=0.65,
|
69 |
api_name="/run"
|
70 |
)
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
72 |
except Exception as e:
|
73 |
st.error(f"Error generating image: {e}")
|
74 |
st.write("Full error details:", e)
|
|
|
48 |
def generate_image(prompt):
|
49 |
try:
|
50 |
result = image_client.predict(
|
51 |
+
prompt, # Image prompt
|
52 |
+
"", # Negative prompt
|
53 |
+
0, # Seed
|
54 |
+
1024, # Width
|
55 |
+
1024, # Height
|
56 |
+
7.0, # Guidance scale
|
57 |
+
28, # Number of inference steps
|
58 |
+
'Euler a', # Sampler
|
59 |
+
'896 x 1152', # Aspect Ratio
|
60 |
+
'(None)', # Style Preset
|
61 |
+
'Standard v3.1', # Quality Tags Presets
|
62 |
+
False, # Use Upscaler
|
63 |
+
0.55, # Upscaler strength
|
64 |
+
1.5, # Upscale by
|
65 |
+
True, # Add Quality Tags
|
|
|
|
|
|
|
66 |
api_name="/run"
|
67 |
)
|
68 |
+
# Check if result is not empty and contains the expected structure
|
69 |
+
if result and isinstance(result, list) and len(result) > 0 and 'image' in result[0]:
|
70 |
+
return result[0]['image']
|
71 |
+
else:
|
72 |
+
st.error("Unexpected result format from the Gradio API.")
|
73 |
+
return None
|
74 |
except Exception as e:
|
75 |
st.error(f"Error generating image: {e}")
|
76 |
st.write("Full error details:", e)
|