xuxw98 commited on
Commit
c9eccf3
1 Parent(s): e1cc733

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +11 -7
  2. example.json +8 -8
app.py CHANGED
@@ -136,13 +136,15 @@ def create_instruct_demo():
136
  with gr.Blocks() as instruct_demo:
137
  with gr.Row():
138
  with gr.Column():
139
- scene_img = gr.Image(label='Scene', type='filepath')
140
- instruction = gr.Textbox(
141
- lines=2, label="Instruction")
142
  object_list = gr.Textbox(
143
- lines=5, label="Input")
 
 
 
144
  max_len = gr.Slider(minimum=256, maximum=1024,
145
- value=512, label="Max length")
146
  with gr.Accordion(label='Advanced options', open=False):
147
  temp = gr.Slider(minimum=0, maximum=1,
148
  value=0.8, label="Temperature")
@@ -155,15 +157,16 @@ def create_instruct_demo():
155
  outputs = gr.Textbox(lines=20, label="Output")
156
 
157
  inputs = [scene_img, instruction, object_list, max_len, temp, top_k]
 
158
 
159
  # 接下来设定具体的example格式
160
  examples_img_list = glob.glob("caption_demo/*.png")
161
  examples = []
162
  for example_img_one in examples_img_list:
163
  scene_name = os.path.basename(example_img_one).split(".")[0]
164
- example_object_list = example_dict[scene_name]["input_display"]
165
  example_instruction = example_dict[scene_name]["instruction"]
166
- example_one = [example_img_one, example_instruction, example_object_list, 1024, 0.8, 200]
167
  examples.append(example_one)
168
 
169
  gr.Examples(
@@ -173,6 +176,7 @@ def create_instruct_demo():
173
  fn=instruct_generate,
174
  cache_examples=os.getenv('SYSTEM') == 'spaces'
175
  )
 
176
  run_botton.click(fn=instruct_generate, inputs=inputs, outputs=outputs)
177
  return instruct_demo
178
 
 
136
  with gr.Blocks() as instruct_demo:
137
  with gr.Row():
138
  with gr.Column():
139
+ scene_img = gr.Image(label='Scene', type='filepath', shape=(1024, 320), height=320, width=1024, interactive=False)
140
+
 
141
  object_list = gr.Textbox(
142
+ lines=5, label="Object List", placeholder="Please click one from the examples below", interactive=False)
143
+
144
+ instruction = gr.Textbox(
145
+ lines=2, label="Instruction", placeholder="Please input the instruction. E.g.Please turn on the lamp")
146
  max_len = gr.Slider(minimum=256, maximum=1024,
147
+ value=1024, label="Max length")
148
  with gr.Accordion(label='Advanced options', open=False):
149
  temp = gr.Slider(minimum=0, maximum=1,
150
  value=0.8, label="Temperature")
 
157
  outputs = gr.Textbox(lines=20, label="Output")
158
 
159
  inputs = [scene_img, instruction, object_list, max_len, temp, top_k]
160
+ # inputs = [scene_img, instruction, object_list]
161
 
162
  # 接下来设定具体的example格式
163
  examples_img_list = glob.glob("caption_demo/*.png")
164
  examples = []
165
  for example_img_one in examples_img_list:
166
  scene_name = os.path.basename(example_img_one).split(".")[0]
167
+ example_object_list = example_dict[scene_name]["input"]
168
  example_instruction = example_dict[scene_name]["instruction"]
169
+ example_one = [example_img_one, example_instruction, example_object_list]
170
  examples.append(example_one)
171
 
172
  gr.Examples(
 
176
  fn=instruct_generate,
177
  cache_examples=os.getenv('SYSTEM') == 'spaces'
178
  )
179
+ # inputs = inputs + [max_len, temp, top_k]
180
  run_botton.click(fn=instruct_generate, inputs=inputs, outputs=outputs)
181
  return instruct_demo
182
 
example.json CHANGED
@@ -1,41 +1,41 @@
1
  {
2
  "FloorPlan21": {
3
- "input": "[apple, chair, blender, sink, pottery, oven, egg, table, shredder_(for_paper), seashell, bread, doorknob, fork, plastic_bag, knife, radio_receiver, drawer, person, coffee_maker, inhaler, toaster, plate, cornice, knob, pear, dining_table, tomato, bottle, scale_(measuring_instrument), toilet_tissue, cushion, latch, scissors, soap, handle, balloon, clock, lightbulb, matchbox, refrigerator, trash_can, backpack, alarm_clock, vase, tape_(sticky_cloth_or_paper), printer, cover, faucet, gourd, pan_(for_cooking), ball, spatula, microwave_oven, dispenser, nailfile, cabinet, sweet_potato, lamp, microscope, pot, cup, suitcase, bowl, thermostat, fume_hood, hinge, mirror, spoon, box,]",
4
  "instruction": "Can you clean the dishes?",
5
  "input_display": "[apple, chair, blender, sink, pottery, oven, egg, table, shredder_(for_paper), seashell, bread, doorknob, fork, plastic_bag, knife, ...]"
6
  },
7
  "FloorPlan24": {
8
- "input": "[apple, chair, sink, oven, figurine, shredder_(for_paper), potholder, doorknob, truffle_(chocolate), fork, towel, stove, napkin, knife, drawer, hotplate, coffee_maker, avocado, chopping_board, stool, bolt, toaster, bowling_ball, hand_towel, plate, speaker_(stero_equipment), tag, piggy_bank, knob, dining_table, tomato, scale_(measuring_instrument), toaster_oven, pitcher_(vessel_for_liquid), painting, handle, wineglass, clock, automatic_washer, ice_maker, lightbulb, refrigerator, trash_can, tray, dishwasher, armoire, faucet, gourd, pan_(for_cooking), spatula, microwave_oven, mug, dispenser, cabinet, fire_extinguisher, kitchen_sink, television_set, lamp, cup, bowl, thermostat, water_jug, hinge, spoon,]",
9
  "instruction": "Please make me an omelette.",
10
  "input_display": "[apple, chair, sink, oven, figurine, shredder_(for_paper), potholder, doorknob, truffle_(chocolate), fork, towel, stove, napkin, knife, drawer, ...]"
11
  },
12
  "FloorPlan221": {
13
- "input": "[chair, sofa, pen, figurine, table, dog, lampshade, doorknob, bed, toy, drawer, person, statue_(sculpture), flowerpot, stool, monitor_(computer_equipment)computer_monitor, desk, pillow, plate, speaker_(stero_equipment), mouse_(computer_equipment), knob, igniter, dining_table, cushion, painting, dragonfly, laptop_computer, remote_control, vase, trash_can, wall_socket, ashtray, coffee_table, card, computer_keyboard, bird, coaster, television_set, lamp, bowl, thermostat, hinge, curtain, box,]",
14
  "instruction": "Could you please close the curtains?",
15
  "input_display": "[chair, sofa, pen, figurine, table, dog, lampshade, doorknob, bed, toy, drawer, person, statue_(sculpture), flowerpot, stool, ...]"
16
  },
17
  "FloorPlan224": {
18
- "input": "[chair, sofa, figurine, table, crate, necklace, dog, dresser, lampshade, doorknob, horse, frisbee, deer, screwdriver, oil_lamp, drawer, sweater, person, statue_(sculpture), flowerpot, stool, dress, pole, monitor_(computer_equipment)computer_monitor, hat, easel, umbrella, desk, pillow, speaker_(stero_equipment), book, knob, fireplace, ottoman, dining_table, toilet_tissue, cushion, painting, latch, handle, bathtub, laptop_computer, remote_control, clock, lightbulb, candle, vase, trash_can, wall_socket, hose, coffee_table, computer_keyboard, spotlight, bird, cabinet, television_set, lamp, harmonium, cup, thermostat, newspaper, curtain, runner_(carpet), box,]",
19
  "instruction": "Can you turn off the light?",
20
  "input_display": "[chair, sofa, figurine, table, crate, necklace, dog, dresser, lampshade, doorknob, horse, frisbee, deer, screwdriver, oil_lamp, ...]"
21
  },
22
  "FloorPlan321": {
23
- "input": "[chair, sofa, figurine, table, quilt, bed, lampshade, doorknob, tissue_paper, headboard, button, pencil, drawer, place_mat, cigar_box, knitting_needle, monitor_(computer_equipment)computer_monitor, desk, pillow, chandelier, book, knob, armchair, ottoman, dining_table, notebook, cushion, painting, vent, laptop_computer, blanket, lightbulb, cellular_telephone, trash_can, alarm_clock, tape_(sticky_cloth_or_paper), faucet, card, computer_keyboard, coaster, nailfile, bicycle, mattress, lamp, car_(automobile), magazine, thermostat, heart, mirror, box,]",
24
  "instruction": "Can you please hand me the pencil on the desk?",
25
  "input_display": "[chair, sofa, figurine, table, quilt, bed, lampshade, doorknob, tissue_paper, headboard, button, pencil, drawer, place_mat, cigar_box, ...]"
26
  },
27
  "FloorPlan323": {
28
- "input": "[chair, sofa, sink, dresser, lampshade, bed, doorknob, toy, teddy_bear, towel, headboard, drawer, place_mat, monitor_(computer_equipment)computer_monitor, desk, pillow, speaker_(stero_equipment), mouse_(computer_equipment), piggy_bank, book, cornice, dining_table, cushion, painting, cigarette_case, handle, laptop_computer, remote_control, candle, trash_can, wall_socket, armoire, corkboard, computer_keyboard, lamp, television_set, telephone, cup, hatbox, bowl, thermostat, hinge, mirror, runner_(carpet), box,]",
29
  "instruction": "Can you pass me the remote control, please?",
30
  "input_display": "[chair, sofa, sink, dresser, lampshade, bed, doorknob, toy, teddy_bear, towel, headboard, drawer, place_mat, monitor_(computer_equipment)computer_monitor, desk, ...]"
31
  },
32
  "FloorPlan422": {
33
- "input": "[knocker_(on_a_door), sink, hook, clothespin, doorknob, tissue_paper, oil_lamp, drawer, cistern, bottle_cap, desk, hand_towel, knob, bottle, dining_table, toilet_tissue, handle, bathtub, towel_rack, bath_mat, candle_holder, bat_(animal), toilet, wooden_spoon, candle, shower_head, refrigerator, trash_can, cover, hair_dryer, armoire, faucet, scrubbing_brush, dispenser, shower_curtain, cabinet, lamp, bath_towel, cup, thermostat, fume_hood, hinge, mirror, paper_towel, broom, box,]",
34
  "instruction": "Open the Cabinet and give me the Soap Bottle",
35
  "input_display": "[knocker_(on_a_door), sink, hook, clothespin, doorknob, tissue_paper, oil_lamp, drawer, cistern, bottle_cap, desk, hand_towel, knob, bottle, dining_table, ...]"
36
  },
37
  "FloorPlan424": {
38
- "input": "[sink, bucket, doorknob, towel, wine_bucket, cistern, washbasin, pipe, hand_towel, knob, bottle, toilet_tissue, soap, handle, towel_rack, candle_holder, lightbulb, candle, shower_head, crucifix, vase, cover, wall_socket, faucet, scrubbing_brush, dispenser, cabinet, lamp, bath_towel, cup, thermostat, hinge, mirror, toilet, eraser,]",
39
  "instruction": "Please clean the sink",
40
  "input_display": "[sink, bucket, doorknob, towel, wine_bucket, cistern, washbasin, pipe, hand_towel, knob, bottle, toilet_tissue, soap, handle, towel_rack, ...]"
41
  }
 
1
  {
2
  "FloorPlan21": {
3
+ "input": "[apple, chair, blender, sink, pottery, oven, egg, table, shredder_(for_paper), seashell, bread, doorknob, fork, plastic_bag, knife, radio_receiver, drawer, person, coffee_maker, inhaler, toaster, plate, cornice, knob, pear, dining_table, tomato, bottle, scale_(measuring_instrument), toilet_tissue, cushion, latch, scissors, soap, handle, balloon, clock, lightbulb, matchbox, refrigerator, trash_can, backpack, alarm_clock, vase, tape_(sticky_cloth_or_paper), printer, cover, faucet, gourd, pan_(for_cooking), ball, spatula, microwave_oven, dispenser, nailfile, cabinet, sweet_potato, lamp, microscope, pot, cup, suitcase, bowl, thermostat, fume_hood, hinge, mirror, spoon, box]",
4
  "instruction": "Can you clean the dishes?",
5
  "input_display": "[apple, chair, blender, sink, pottery, oven, egg, table, shredder_(for_paper), seashell, bread, doorknob, fork, plastic_bag, knife, ...]"
6
  },
7
  "FloorPlan24": {
8
+ "input": "[apple, chair, sink, oven, figurine, shredder_(for_paper), potholder, doorknob, truffle_(chocolate), fork, towel, stove, napkin, knife, drawer, hotplate, coffee_maker, avocado, chopping_board, stool, bolt, toaster, bowling_ball, hand_towel, plate, speaker_(stero_equipment), tag, piggy_bank, knob, dining_table, tomato, scale_(measuring_instrument), toaster_oven, pitcher_(vessel_for_liquid), painting, handle, wineglass, clock, automatic_washer, ice_maker, lightbulb, refrigerator, trash_can, tray, dishwasher, armoire, faucet, gourd, pan_(for_cooking), spatula, microwave_oven, mug, dispenser, cabinet, fire_extinguisher, kitchen_sink, television_set, lamp, cup, bowl, thermostat, water_jug, hinge, spoon]",
9
  "instruction": "Please make me an omelette.",
10
  "input_display": "[apple, chair, sink, oven, figurine, shredder_(for_paper), potholder, doorknob, truffle_(chocolate), fork, towel, stove, napkin, knife, drawer, ...]"
11
  },
12
  "FloorPlan221": {
13
+ "input": "[chair, sofa, pen, figurine, table, dog, lampshade, doorknob, bed, toy, drawer, person, statue_(sculpture), flowerpot, stool, monitor_(computer_equipment)computer_monitor, desk, pillow, plate, speaker_(stero_equipment), mouse_(computer_equipment), knob, igniter, dining_table, cushion, painting, dragonfly, laptop_computer, remote_control, vase, trash_can, wall_socket, ashtray, coffee_table, card, computer_keyboard, bird, coaster, television_set, lamp, bowl, thermostat, hinge, curtain, box]",
14
  "instruction": "Could you please close the curtains?",
15
  "input_display": "[chair, sofa, pen, figurine, table, dog, lampshade, doorknob, bed, toy, drawer, person, statue_(sculpture), flowerpot, stool, ...]"
16
  },
17
  "FloorPlan224": {
18
+ "input": "[chair, sofa, figurine, table, crate, necklace, dog, dresser, lampshade, doorknob, horse, frisbee, deer, screwdriver, oil_lamp, drawer, sweater, person, statue_(sculpture), flowerpot, stool, dress, pole, monitor_(computer_equipment)computer_monitor, hat, easel, umbrella, desk, pillow, speaker_(stero_equipment), book, knob, fireplace, ottoman, dining_table, toilet_tissue, cushion, painting, latch, handle, bathtub, laptop_computer, remote_control, clock, lightbulb, candle, vase, trash_can, wall_socket, hose, coffee_table, computer_keyboard, spotlight, bird, cabinet, television_set, lamp, harmonium, cup, thermostat, newspaper, curtain, runner_(carpet), box]",
19
  "instruction": "Can you turn off the light?",
20
  "input_display": "[chair, sofa, figurine, table, crate, necklace, dog, dresser, lampshade, doorknob, horse, frisbee, deer, screwdriver, oil_lamp, ...]"
21
  },
22
  "FloorPlan321": {
23
+ "input": "[chair, sofa, figurine, table, quilt, bed, lampshade, doorknob, tissue_paper, headboard, button, pencil, drawer, place_mat, cigar_box, knitting_needle, monitor_(computer_equipment)computer_monitor, desk, pillow, chandelier, book, knob, armchair, ottoman, dining_table, notebook, cushion, painting, vent, laptop_computer, blanket, lightbulb, cellular_telephone, trash_can, alarm_clock, tape_(sticky_cloth_or_paper), faucet, card, computer_keyboard, coaster, nailfile, bicycle, mattress, lamp, car_(automobile), magazine, thermostat, heart, mirror, box]",
24
  "instruction": "Can you please hand me the pencil on the desk?",
25
  "input_display": "[chair, sofa, figurine, table, quilt, bed, lampshade, doorknob, tissue_paper, headboard, button, pencil, drawer, place_mat, cigar_box, ...]"
26
  },
27
  "FloorPlan323": {
28
+ "input": "[chair, sofa, sink, dresser, lampshade, bed, doorknob, toy, teddy_bear, towel, headboard, drawer, place_mat, monitor_(computer_equipment)computer_monitor, desk, pillow, speaker_(stero_equipment), mouse_(computer_equipment), piggy_bank, book, cornice, dining_table, cushion, painting, cigarette_case, handle, laptop_computer, remote_control, candle, trash_can, wall_socket, armoire, corkboard, computer_keyboard, lamp, television_set, telephone, cup, hatbox, bowl, thermostat, hinge, mirror, runner_(carpet), box]",
29
  "instruction": "Can you pass me the remote control, please?",
30
  "input_display": "[chair, sofa, sink, dresser, lampshade, bed, doorknob, toy, teddy_bear, towel, headboard, drawer, place_mat, monitor_(computer_equipment)computer_monitor, desk, ...]"
31
  },
32
  "FloorPlan422": {
33
+ "input": "[knocker_(on_a_door), sink, hook, clothespin, doorknob, tissue_paper, oil_lamp, drawer, cistern, bottle_cap, desk, hand_towel, knob, bottle, dining_table, toilet_tissue, handle, bathtub, towel_rack, bath_mat, candle_holder, bat_(animal), toilet, wooden_spoon, candle, shower_head, refrigerator, trash_can, cover, hair_dryer, armoire, faucet, scrubbing_brush, dispenser, shower_curtain, cabinet, lamp, bath_towel, cup, thermostat, fume_hood, hinge, mirror, paper_towel, broom, box]",
34
  "instruction": "Open the Cabinet and give me the Soap Bottle",
35
  "input_display": "[knocker_(on_a_door), sink, hook, clothespin, doorknob, tissue_paper, oil_lamp, drawer, cistern, bottle_cap, desk, hand_towel, knob, bottle, dining_table, ...]"
36
  },
37
  "FloorPlan424": {
38
+ "input": "[sink, bucket, doorknob, towel, wine_bucket, cistern, washbasin, pipe, hand_towel, knob, bottle, toilet_tissue, soap, handle, towel_rack, candle_holder, lightbulb, candle, shower_head, crucifix, vase, cover, wall_socket, faucet, scrubbing_brush, dispenser, cabinet, lamp, bath_towel, cup, thermostat, hinge, mirror, toilet, eraser]",
39
  "instruction": "Please clean the sink",
40
  "input_display": "[sink, bucket, doorknob, towel, wine_bucket, cistern, washbasin, pipe, hand_towel, knob, bottle, toilet_tissue, soap, handle, towel_rack, ...]"
41
  }