dreamdrop-art commited on
Commit
b912fed
1 Parent(s): d7de7d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -1
app.py CHANGED
@@ -269,6 +269,17 @@ css = """
269
  }
270
  """
271
 
 
 
 
 
 
 
 
 
 
 
 
272
  with gr.Blocks(css=css) as demo:
273
  with gr.Row():
274
  with gr.Column(scale=6):
@@ -507,6 +518,11 @@ with gr.Blocks(css=css) as demo:
507
  # gr.load("models/mattmdjaga/segformer_b2_clothes", title="SegFormer Segmentation")
508
  with gr.Tab("Visual Question Answering"):
509
  gr.load("models/dandelin/vilt-b32-finetuned-vqa", title="ViLT VQA")
 
 
 
 
 
 
510
 
511
-
512
  demo.queue(max_size=80, api_open=False).launch(max_threads=256, show_api=False)
 
269
  }
270
  """
271
 
272
+ def change_checkpoint(name, progress=gr.Progress()):
273
+ progress(0, desc="Starting")
274
+ time.sleep(0.5)
275
+ progress(0.25, desc="Changing")
276
+ time.sleep(1)
277
+ progress(0.95, desc="Loading to GPU")
278
+ time.sleep(0.5)
279
+ progress(0.100, desc="Ready")
280
+ return name
281
+
282
+
283
  with gr.Blocks(css=css) as demo:
284
  with gr.Row():
285
  with gr.Column(scale=6):
 
518
  # gr.load("models/mattmdjaga/segformer_b2_clothes", title="SegFormer Segmentation")
519
  with gr.Tab("Visual Question Answering"):
520
  gr.load("models/dandelin/vilt-b32-finetuned-vqa", title="ViLT VQA")
521
+
522
+ model_cache = gr.Textbox(interactive=False, visible=False)
523
+ hf_model_cache = gr.Textbox(interactive=False, visible=False)
524
+ model.change(change_checkpoint, inputs=model, outputs=model_cache)
525
+ hf_model.change(change_checkpoint, inputs=hf_model, outputs=hf_model_cache)
526
+
527
 
 
528
  demo.queue(max_size=80, api_open=False).launch(max_threads=256, show_api=False)