bluenevus commited on
Commit
d46dfb7
·
verified ·
1 Parent(s): 4a41d50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -11
app.py CHANGED
@@ -113,29 +113,22 @@ def generate_image(stability_api_key, enhanced_prompt, style, negative_prompt):
113
  }
114
 
115
  data = {
116
- "prompt": f"{enhanced_prompt}, Style: {style}, highly detailed, photorealistic, high quality, natural lighting, realistic textures and colors",
117
  "negative_prompt": negative_prompt,
118
  "model": "sd3.5-large-turbo",
119
  "output_format": "jpeg",
120
  "width": 1024,
121
  "height": 1024,
122
  "num_images": 1,
123
- "steps": 30, # Increased from 20 to 30
124
- "cfg_scale": 7,
125
  }
126
 
127
  try:
128
- response = requests.post(url, headers=headers, files={"none": ''}, data=data, timeout=60) # Added 60-second timeout
129
  response.raise_for_status()
130
 
131
- logging.debug(f"Response headers: {response.headers}")
132
- logging.debug(f"Response content type: {response.headers.get('content-type')}")
133
-
134
  if response.headers.get('content-type').startswith('image/'):
135
- image_data = response.content
136
- if len(image_data) < 1000: # Check if the image data is too small (likely incomplete)
137
- raise Exception("Received incomplete image data")
138
- return image_data
139
  else:
140
  error_message = response.text
141
  logging.error(f"Unexpected content type: {response.headers.get('content-type')}. Response: {error_message}")
 
113
  }
114
 
115
  data = {
116
+ "prompt": f"{enhanced_prompt}, Style: {style}, highly detailed, photorealistic, high quality",
117
  "negative_prompt": negative_prompt,
118
  "model": "sd3.5-large-turbo",
119
  "output_format": "jpeg",
120
  "width": 1024,
121
  "height": 1024,
122
  "num_images": 1,
123
+ "steps": 4, # SD3.5 Large Turbo generates high-quality images in just 4 steps
 
124
  }
125
 
126
  try:
127
+ response = requests.post(url, headers=headers, files={"none": ''}, data=data)
128
  response.raise_for_status()
129
 
 
 
 
130
  if response.headers.get('content-type').startswith('image/'):
131
+ return response.content
 
 
 
132
  else:
133
  error_message = response.text
134
  logging.error(f"Unexpected content type: {response.headers.get('content-type')}. Response: {error_message}")