akhaliq HF staff commited on
Commit
4af8340
·
verified ·
1 Parent(s): 38370aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -42
app.py CHANGED
@@ -2,48 +2,14 @@ import gradio as gr
2
  import spaces
3
  import transformers_gradio
4
 
5
- # Load models
6
- models = {
7
- "Llama": {
8
- "name": "allenai/Llama-3.1-Tulu-3-8B",
9
- "src": transformers_gradio.registry
10
- },
11
- "OLMo": {
12
- "name": "akhaliq/olmo-anychat",
13
- "src": "spaces"
14
- }
15
- }
16
 
17
- def load_model(model_choice):
18
- model_info = models[model_choice]
19
- demo = gr.load(name=model_info["name"], src=model_info["src"])
20
-
21
- if model_choice == "Llama":
22
- demo.fn = spaces.GPU()(demo.fn)
23
-
24
- # Disable API names
25
- for fn in demo.fns.values():
26
- fn.api_name = False
27
-
28
- return demo
29
 
30
  if __name__ == "__main__":
31
- with gr.Blocks() as interface:
32
- model_dropdown = gr.Dropdown(
33
- choices=list(models.keys()),
34
- value="Llama",
35
- label="Select Model"
36
- )
37
-
38
- demo_container = gr.Group()
39
-
40
- def update_demo(model_choice):
41
- return load_model(model_choice)
42
-
43
- model_dropdown.change(
44
- fn=update_demo,
45
- inputs=[model_dropdown],
46
- outputs=[demo_container]
47
- )
48
-
49
- interface.launch()
 
2
  import spaces
3
  import transformers_gradio
4
 
5
+ # Load Llama model
6
+ demo = gr.load(name="allenai/Llama-3.1-Tulu-3-8B", src=transformers_gradio.registry)
7
+ demo.fn = spaces.GPU()(demo.fn)
 
 
 
 
 
 
 
 
8
 
9
+
10
+ # Disable API names for both demos
11
+ for fn in demo.fns.values():
12
+ fn.api_name = False
 
 
 
 
 
 
 
 
13
 
14
  if __name__ == "__main__":
15
+ demo.launch()