Omnibus commited on
Commit
8725491
1 Parent(s): 80cd37d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -1,7 +1,6 @@
1
- +import spaces
2
-
3
  from transformers import pipeline
4
-
5
 
6
  pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
7
 
@@ -22,14 +21,20 @@ PROMPT_FOR_GENERATION_FORMAT = """{intro}
22
  example = "James decides to run 3 sprints 3 times a week. He runs 60 meters each sprint. How many total meters does he run a week? Explain before answering."
23
  fmt_ex = PROMPT_FOR_GENERATION_FORMAT.format(instruction=example)
24
 
25
- +@spaces.GPU
26
  def run():
27
  with torch.autocast('cuda', dtype=torch.bfloat16):
28
- print(
29
  pipe('Here is a recipe for vegan banana bread:\n',
30
  max_new_tokens=100,
31
  do_sample=True,
32
  use_cache=True))
33
- run()
34
 
35
 
 
 
 
 
 
 
 
 
1
+ import spaces
 
2
  from transformers import pipeline
3
+ import gradio as gr
4
 
5
  pipe = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda:0')
6
 
 
21
  example = "James decides to run 3 sprints 3 times a week. He runs 60 meters each sprint. How many total meters does he run a week? Explain before answering."
22
  fmt_ex = PROMPT_FOR_GENERATION_FORMAT.format(instruction=example)
23
 
24
+ @spaces.GPU
25
  def run():
26
  with torch.autocast('cuda', dtype=torch.bfloat16):
27
+ return(
28
  pipe('Here is a recipe for vegan banana bread:\n',
29
  max_new_tokens=100,
30
  do_sample=True,
31
  use_cache=True))
 
32
 
33
 
34
+
35
+ with gr.Blocks() as app:
36
+ btn = gr.Button()
37
+ outp=gr.Textbox()
38
+ btn.click(run,None,outp)
39
+ app.launch()
40
+