randeom commited on
Commit
cfe386b
·
verified ·
1 Parent(s): 74e0f7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -19
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=prompt,
52
- negative_prompt="",
53
- seed=0,
54
- custom_width=1024,
55
- custom_height=1024,
56
- guidance_scale=7.0,
57
- num_inference_steps=28,
58
- sampler="Euler a",
59
- aspect_ratio_selector="896 x 1152",
60
- style_selector="(None)",
61
- quality_selector="Standard v3.1",
62
- use_upscaler=False,
63
- upscaler_strength=0.55,
64
- upscale_by=1.5,
65
- add_quality_tags=True,
66
- isImg2Img=False,
67
- img_path=None,
68
- img2img_strength=0.65,
69
  api_name="/run"
70
  )
71
- return result[0]['image']
 
 
 
 
 
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)