Ashoka74 commited on
Commit
d3e8e81
Β·
verified Β·
1 Parent(s): d068918

Update gradio_demo.py

Browse files
Files changed (1) hide show
  1. gradio_demo.py +12 -11
gradio_demo.py CHANGED
@@ -952,7 +952,7 @@ def process_image(input_image, input_text):
952
  # Run DINO-X detection
953
  task = DinoxTask(
954
  image_url=image_url,
955
- prompts=[TextPrompt(text=input_text)]
956
  targets=[DetectionTarget.BBox, DetectionTarget.Mask]
957
  )
958
 
@@ -1079,7 +1079,7 @@ def process_image(input_image, input_text):
1079
 
1080
  block = gr.Blocks().queue()
1081
  with block:
1082
- with gr.Tab("Text", visible=True):
1083
  with gr.Row():
1084
  gr.Markdown("## Product Placement from Text")
1085
  with gr.Row():
@@ -1255,11 +1255,8 @@ with block:
1255
  type='value'
1256
  )
1257
 
1258
- example_prompts = gr.Dataset(
1259
- samples=quick_prompts,
1260
- label='Prompt Quick List',
1261
- components=[prompt]
1262
- )
1263
  # bg_gallery = gr.Gallery(
1264
  # height=450,
1265
  # label='Background Quick List',
@@ -1270,7 +1267,7 @@ with block:
1270
  relight_button_bg = gr.Button(value="Relight")
1271
 
1272
  # Additional settings
1273
- with gr.Group():
1274
  with gr.Row():
1275
  num_samples = gr.Slider(label="Images", minimum=1, maximum=12, value=1, step=1)
1276
  seed = gr.Number(label="Seed", value=12345, precision=0)
@@ -1280,13 +1277,13 @@ with block:
1280
 
1281
  with gr.Accordion("Advanced options", open=False):
1282
  steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=20, step=1)
1283
- cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=32.0, value=7.0, step=0.01)
1284
  highres_scale = gr.Slider(label="Highres Scale", minimum=1.0, maximum=2.0, value=1.2, step=0.01)
1285
  highres_denoise = gr.Slider(label="Highres Denoise", minimum=0.1, maximum=0.9, value=0.5, step=0.01)
1286
- a_prompt = gr.Textbox(label="Added Prompt", value='best quality')
1287
  n_prompt = gr.Textbox(
1288
  label="Negative Prompt",
1289
- value='lowres, bad anatomy, bad hands, cropped, worst quality'
1290
  )
1291
 
1292
  with gr.Column():
@@ -1314,6 +1311,10 @@ with block:
1314
  outputs=[depth_image], show_progress=True
1315
  )
1316
 
 
 
 
 
1317
  # def update_position(background, x_pos, y_pos, scale):
1318
  # """Update composite when position changes"""
1319
  # global original_bg
 
952
  # Run DINO-X detection
953
  task = DinoxTask(
954
  image_url=image_url,
955
+ prompts=[TextPrompt(text=input_text)],
956
  targets=[DetectionTarget.BBox, DetectionTarget.Mask]
957
  )
958
 
 
1079
 
1080
  block = gr.Blocks().queue()
1081
  with block:
1082
+ with gr.Tab("Text", visible=False):
1083
  with gr.Row():
1084
  gr.Markdown("## Product Placement from Text")
1085
  with gr.Row():
 
1255
  type='value'
1256
  )
1257
 
1258
+ example_quick_subjects = gr.Dataset(samples=quick_subjects, label='Subject Quick List', samples_per_page=1000, components=[prompt])
1259
+ example_quick_prompts = gr.Dataset(samples=quick_prompts, label='Lighting Quick List', samples_per_page=1000, components=[prompt])
 
 
 
1260
  # bg_gallery = gr.Gallery(
1261
  # height=450,
1262
  # label='Background Quick List',
 
1267
  relight_button_bg = gr.Button(value="Relight")
1268
 
1269
  # Additional settings
1270
+ with gr.Group(visible=False):
1271
  with gr.Row():
1272
  num_samples = gr.Slider(label="Images", minimum=1, maximum=12, value=1, step=1)
1273
  seed = gr.Number(label="Seed", value=12345, precision=0)
 
1277
 
1278
  with gr.Accordion("Advanced options", open=False):
1279
  steps = gr.Slider(label="Steps", minimum=1, maximum=100, value=20, step=1)
1280
+ cfg = gr.Slider(label="CFG Scale", minimum=1.0, maximum=32.0, value=7.0, step=0.01, visible=False)
1281
  highres_scale = gr.Slider(label="Highres Scale", minimum=1.0, maximum=2.0, value=1.2, step=0.01)
1282
  highres_denoise = gr.Slider(label="Highres Denoise", minimum=0.1, maximum=0.9, value=0.5, step=0.01)
1283
+ a_prompt = gr.Textbox(label="Added Prompt", value='best quality', visible=False)
1284
  n_prompt = gr.Textbox(
1285
  label="Negative Prompt",
1286
+ value='lowres, bad anatomy, bad hands, cropped, worst quality', visible=False
1287
  )
1288
 
1289
  with gr.Column():
 
1311
  outputs=[depth_image], show_progress=True
1312
  )
1313
 
1314
+
1315
+ example_quick_prompts.click(lambda x, y: ', '.join(y.split(', ')[:2] + [x[0]]), inputs=[example_quick_prompts, prompt], outputs=prompt, show_progress=False, queue=False)
1316
+ example_quick_subjects.click(lambda x: x[0], inputs=example_quick_subjects, outputs=prompt, show_progress=False, queue=False)
1317
+
1318
  # def update_position(background, x_pos, y_pos, scale):
1319
  # """Update composite when position changes"""
1320
  # global original_bg