tunght commited on
Commit
29438c5
·
1 Parent(s): 5a4e46d

fix refresh not reset visible counter bug

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -156,6 +156,7 @@ def detect_features(image_paths, garment_type, language="English"):
156
  def generate(*data):
157
  global visible
158
  print("visible", visible)
 
159
 
160
  feature, image, garment_type, model, temperature, excluded_words, included_words = data[:7]
161
  struct_ref = data[7:]
@@ -181,7 +182,10 @@ def generate(*data):
181
  batch = []
182
  for i in range(visible + 1):
183
  structure = struct_ref[2 * i]
184
- reference = struct_ref[2 * i + 1]
 
 
 
185
  messages = [
186
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites."""),
187
  HumanMessage(content=f"""Write a product description with the following features.
@@ -259,6 +263,8 @@ def show_advanced(model, temperature):
259
 
260
 
261
  with gr.Blocks() as demo:
 
 
262
  with gr.Row():
263
  with gr.Column():
264
  feature = gr.Textbox(label="Features", value=feature_text, lines=3, interactive=True)
@@ -275,6 +281,7 @@ with gr.Blocks() as demo:
275
  # advanced = gr.Button(value="Advanced")
276
 
277
  with gr.Column():
 
278
  struct_ref = [val for i in range(10) for val in
279
  [gr.Textbox(label=f"Structure {i}", lines=10, value="", interactive=True, visible=i <= visible),
280
  gr.Textbox(label=f"Reference copy {i}", lines=3, value="", interactive=True, visible=i <= visible)]]
 
156
  def generate(*data):
157
  global visible
158
  print("visible", visible)
159
+
160
 
161
  feature, image, garment_type, model, temperature, excluded_words, included_words = data[:7]
162
  struct_ref = data[7:]
 
182
  batch = []
183
  for i in range(visible + 1):
184
  structure = struct_ref[2 * i]
185
+ reference = struct_ref[2 * i + 1]
186
+ if len((structure + reference).strip()) == 0:
187
+ visible = i
188
+ break
189
  messages = [
190
  SystemMessage(content=f"""You are a helpful assistant that writes about products for ecommerce websites."""),
191
  HumanMessage(content=f"""Write a product description with the following features.
 
263
 
264
 
265
  with gr.Blocks() as demo:
266
+ visible = 0
267
+ print("Building interface")
268
  with gr.Row():
269
  with gr.Column():
270
  feature = gr.Textbox(label="Features", value=feature_text, lines=3, interactive=True)
 
281
  # advanced = gr.Button(value="Advanced")
282
 
283
  with gr.Column():
284
+ visible = 0
285
  struct_ref = [val for i in range(10) for val in
286
  [gr.Textbox(label=f"Structure {i}", lines=10, value="", interactive=True, visible=i <= visible),
287
  gr.Textbox(label=f"Reference copy {i}", lines=3, value="", interactive=True, visible=i <= visible)]]