Gary3410 commited on
Commit
43dd0bd
·
1 Parent(s): c8e5690

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -42,6 +42,11 @@ def instruct_generate(
42
  top_k: The number of top most probable tokens to consider in the sampling process.
43
  temperature: A value controlling the randomness of the sampling process. Higher values result in more random
44
  """
 
 
 
 
 
45
  output = [prompt, input, max_new_tokens, top_k, temperature]
46
  print(output)
47
  return output
@@ -56,7 +61,9 @@ max_batch_size = 1
56
  with open(example_path, 'r') as f:
57
  content = f.read()
58
  example_dict = json.loads(content)
59
-
 
 
60
 
61
  def create_instruct_demo():
62
  with gr.Blocks() as instruct_demo:
@@ -87,7 +94,7 @@ def create_instruct_demo():
87
  examples = []
88
  for example_img_one in examples_img_list:
89
  scene_name = os.path.basename(example_img_one).split(".")[0]
90
- example_object_list = example_dict[scene_name]["input"]
91
  example_instruction = example_dict[scene_name]["instruction"]
92
  example_one = [example_img_one, example_instruction, example_object_list, 512, 0.8, 200]
93
  examples.append(example_one)
 
42
  top_k: The number of top most probable tokens to consider in the sampling process.
43
  temperature: A value controlling the randomness of the sampling process. Higher values result in more random
44
  """
45
+ scene_name = os.path.basename(img_path).split(".")[0]
46
+ if input in input_value_list:
47
+ input = example_dict[scene_name]["input"]
48
+ if "..." in input:
49
+ input = input.replace("...", "")
50
  output = [prompt, input, max_new_tokens, top_k, temperature]
51
  print(output)
52
  return output
 
61
  with open(example_path, 'r') as f:
62
  content = f.read()
63
  example_dict = json.loads(content)
64
+ input_value_list = []
65
+ for scene_id, scene_dict in example_dict.items():
66
+ input_value_list.append(scene_dict["input_display"])
67
 
68
  def create_instruct_demo():
69
  with gr.Blocks() as instruct_demo:
 
94
  examples = []
95
  for example_img_one in examples_img_list:
96
  scene_name = os.path.basename(example_img_one).split(".")[0]
97
+ example_object_list = example_dict[scene_name]["input_display"]
98
  example_instruction = example_dict[scene_name]["instruction"]
99
  example_one = [example_img_one, example_instruction, example_object_list, 512, 0.8, 200]
100
  examples.append(example_one)