superlazycoder commited on
Commit
fdd4431
·
verified ·
1 Parent(s): 695c5a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -8
app.py CHANGED
@@ -60,6 +60,39 @@ def reject(prompt, negative_prompt, seed, randomize_seed, width, height, guidanc
60
 
61
  return image
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  examples = [
64
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
65
  "An astronaut riding a green horse",
@@ -100,6 +133,7 @@ with gr.Blocks(css=css) as demo:
100
  right_button = gr.Button("Right", scale=0)
101
 
102
  result = gr.Image(label="Result", show_label=False)
 
103
 
104
  with gr.Accordion("Advanced Settings", open=False):
105
 
@@ -161,12 +195,6 @@ with gr.Blocks(css=css) as demo:
161
  inputs = [prompt]
162
  )
163
 
164
- run_button.click(
165
- fn = infer,
166
- inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
167
- outputs = [result]
168
- )
169
-
170
  left_button.click(
171
  fn = reject,
172
  inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
@@ -174,9 +202,9 @@ with gr.Blocks(css=css) as demo:
174
  )
175
 
176
  right_button.click(
177
- fn = reject,
178
  inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
179
- outputs = [result]
180
  )
181
 
182
  demo.queue().launch()
 
60
 
61
  return image
62
 
63
+
64
+ @spaces.GPU
65
+ def accept(*args):
66
+
67
+ conv_id = args[0]
68
+ '''
69
+ markdown_blocks = list(args[1:-2])
70
+ labels = args[-2]
71
+
72
+ data = {'conv_id': conv_id, 'labels': labels}
73
+ with open(f"./labels/conv_{conv_id}", 'w') as f:
74
+ json.dump(data, f, indent=4)
75
+
76
+ new_conversation = get_conversation()
77
+ new_conv_id = new_conversation['conv_id']
78
+ new_transcript = pad_transcript(new_conversation['transcript'], max_conversation_length)
79
+
80
+ for i in range(max_conversation_length):
81
+ if new_transcript[i]['speaker'] != '':
82
+ markdown_blocks[i] = gr.Markdown(f"""<br>**{new_transcript[i]['speaker']}**: {new_transcript[i]['response']}""",
83
+ visible=True)
84
+ else:
85
+ markdown_blocks[i] = gr.Markdown("", visible=False)
86
+
87
+ new_labels = gr.CheckboxGroup(choices=checkbox_choices,
88
+ label="",
89
+ visible=False)
90
+ conv_len = gr.Number(value=len(new_transcript), visible=False)
91
+
92
+ return [new_conv_id] + list(markdown_blocks) + [labels] + [new_labels] + [conv_len]
93
+ '''
94
+
95
+
96
  examples = [
97
  "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
98
  "An astronaut riding a green horse",
 
133
  right_button = gr.Button("Right", scale=0)
134
 
135
  result = gr.Image(label="Result", show_label=False)
136
+ conv_id_element = gr.Text(value=1, visible=False)
137
 
138
  with gr.Accordion("Advanced Settings", open=False):
139
 
 
195
  inputs = [prompt]
196
  )
197
 
 
 
 
 
 
 
198
  left_button.click(
199
  fn = reject,
200
  inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
 
202
  )
203
 
204
  right_button.click(
205
+ fn = accept,
206
  inputs = [prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps],
207
+ outputs = [conv_id_element]
208
  )
209
 
210
  demo.queue().launch()