vibs08 commited on
Commit
93d27bc
·
verified ·
1 Parent(s): 0f95895

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -97,7 +97,7 @@ def gen_pos_prompt(text):
97
  pos_prompt = json.loads(response.get('body').read())['results'][0]['outputText']
98
  return pos_prompt
99
 
100
- def generate_image_from_text(pos_prompt):
101
  new_prompt = gen_pos_prompt(pos_prompt)
102
  print(new_prompt)
103
  neg_prompt = '''Detailed, complex textures, intricate patterns, realistic lighting, high contrast, reflections, fuzzy surface, realistic proportions, photographic quality, vibrant colors, detailed background, shadows, disfigured, deformed, ugly, multiple, duplicate.'''
@@ -109,7 +109,7 @@ def generate_image_from_text(pos_prompt):
109
  'textToImageParams': {'text': new_prompt,
110
  'negativeText': neg_prompt},
111
  'imageGenerationConfig': {"cfgScale":8,
112
- "seed":0,
113
  "width":512,
114
  "height":512,
115
  "numberOfImages":1
@@ -159,9 +159,9 @@ def generate(image, mc_resolution, formats=["obj", "glb"]):
159
 
160
  return mesh_path_obj.name, mesh_path_glb.name
161
 
162
- def run_example(text_prompt, do_remove_background, foreground_ratio, mc_resolution):
163
  # Step 1: Generate the image from text prompt
164
- image_pil = generate_image_from_text(text_prompt)
165
 
166
  # Step 2: Preprocess the image
167
  preprocessed = preprocess(image_pil, do_remove_background, foreground_ratio)
@@ -188,6 +188,7 @@ with gr.Blocks() as demo:
188
  elem_id="content_image",
189
  visible=False # Hidden since we generate the image from text
190
  )
 
191
  processed_image = gr.Image(label="Processed Image", interactive=False, visible=False)
192
  with gr.Row():
193
  with gr.Group():
@@ -237,7 +238,7 @@ with gr.Blocks() as demo:
237
  # )
238
  submit.click(fn=check_input_image, inputs=[text_prompt]).success(
239
  fn=run_example,
240
- inputs=[text_prompt, do_remove_background, foreground_ratio, mc_resolution],
241
  outputs=[processed_image, output_model_obj, output_model_glb],
242
  # outputs=[output_model_obj, output_model_glb],
243
  )
 
97
  pos_prompt = json.loads(response.get('body').read())['results'][0]['outputText']
98
  return pos_prompt
99
 
100
+ def generate_image_from_text(pos_prompt, seed):
101
  new_prompt = gen_pos_prompt(pos_prompt)
102
  print(new_prompt)
103
  neg_prompt = '''Detailed, complex textures, intricate patterns, realistic lighting, high contrast, reflections, fuzzy surface, realistic proportions, photographic quality, vibrant colors, detailed background, shadows, disfigured, deformed, ugly, multiple, duplicate.'''
 
109
  'textToImageParams': {'text': new_prompt,
110
  'negativeText': neg_prompt},
111
  'imageGenerationConfig': {"cfgScale":8,
112
+ "seed":int(seed),
113
  "width":512,
114
  "height":512,
115
  "numberOfImages":1
 
159
 
160
  return mesh_path_obj.name, mesh_path_glb.name
161
 
162
+ def run_example(text_prompt,seed do_remove_background, foreground_ratio, mc_resolution):
163
  # Step 1: Generate the image from text prompt
164
+ image_pil = generate_image_from_text(text_prompt, seed)
165
 
166
  # Step 2: Preprocess the image
167
  preprocessed = preprocess(image_pil, do_remove_background, foreground_ratio)
 
188
  elem_id="content_image",
189
  visible=False # Hidden since we generate the image from text
190
  )
191
+ seed = gr.Number(value=0)
192
  processed_image = gr.Image(label="Processed Image", interactive=False, visible=False)
193
  with gr.Row():
194
  with gr.Group():
 
238
  # )
239
  submit.click(fn=check_input_image, inputs=[text_prompt]).success(
240
  fn=run_example,
241
+ inputs=[text_prompt, seed, do_remove_background, foreground_ratio, mc_resolution],
242
  outputs=[processed_image, output_model_obj, output_model_glb],
243
  # outputs=[output_model_obj, output_model_glb],
244
  )