richardkimsm89 commited on
Commit
58d9279
·
verified ·
1 Parent(s): f56245e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -2
app.py CHANGED
@@ -1,11 +1,38 @@
 
 
 
1
  import gradio as gr
2
 
3
- gr.load(
4
  "google/gemma-2-2b-it",
5
  src = "models",
6
  inputs = [gr.Textbox(label = "Input")],
7
  outputs = [gr.Textbox(label = "Output")],
8
- title = "Demo",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  examples = [
10
  ["Hello, World."]
11
  ]
 
1
+ """
2
+ # Inference
3
+
4
  import gradio as gr
5
 
6
+ app = gr.load(
7
  "google/gemma-2-2b-it",
8
  src = "models",
9
  inputs = [gr.Textbox(label = "Input")],
10
  outputs = [gr.Textbox(label = "Output")],
11
+ title = "Gemma",
12
+ examples = [
13
+ ["Hello, World."]
14
+ ]
15
+ ).launch()
16
+ """
17
+
18
+ # Pipeline
19
+
20
+ import gradio as gr
21
+ from transformers import pipeline
22
+
23
+ pipe = pipeline(model = "google/gemma-2-2b-it")
24
+
25
+ def fn(input):
26
+ output = pipe(
27
+ input,
28
+ )
29
+ return output[0]["generated_text"]#[len(input):]
30
+
31
+ app = gr.Interface(
32
+ fn = fn,
33
+ inputs = [gr.Textbox(label = "Input")],
34
+ outputs = [gr.Textbox(label = "Output")],
35
+ title = "Gemma",
36
  examples = [
37
  ["Hello, World."]
38
  ]