davidberenstein1957 HF staff commited on
Commit
9754519
·
verified ·
1 Parent(s): e0198be

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -16,10 +16,13 @@ with gr.Blocks() as demo:
16
 
17
  @gr.render(inputs=[search_in], triggers=[search_in.submit])
18
  def get_interface_from_repo(repo_id: str, progress: gr.Progress = gr.Progress()):
19
- progress(0.0, desc="Loading model")
20
- pipe = pipeline(model=repo_id)
21
- progress(1.0, desc="Model loaded")
22
- gr.Interface.from_pipeline(pipe)
 
 
 
23
 
24
 
25
  if __name__ == "__main__":
 
16
 
17
  @gr.render(inputs=[search_in], triggers=[search_in.submit])
18
  def get_interface_from_repo(repo_id: str, progress: gr.Progress = gr.Progress()):
19
+ try:
20
+ progress(0.0, desc="Loading model")
21
+ pipe = pipeline(model=repo_id)
22
+ progress(1.0, desc="Model loaded")
23
+ gr.Interface.from_pipeline(pipe, flagging_mode="never")
24
+ except Exception as e:
25
+ gr.Markdown(f"This model is not supported. It might be too large or it does not work with Gradio. Try another model. Failed with expection: {e}")
26
 
27
 
28
  if __name__ == "__main__":