Jiading Fang commited on
Commit
5423fbb
·
1 Parent(s): 0826b12

use gradio app

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -1
  2. app.py +17 -0
  3. requirements.txt +1 -0
Dockerfile CHANGED
@@ -24,4 +24,6 @@ WORKDIR $HOME/app
24
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
  COPY --chown=user . $HOME/app
26
 
27
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
24
  # Copy the current directory contents into the container at $HOME/app setting the owner to the user
25
  COPY --chown=user . $HOME/app
26
 
27
+ CMD ["python3", "app.py"]
28
+
29
+ # CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ pipe_flan = pipeline("text2text-generation", model="google/flan-t5-small")
5
+
6
+ def t5(input):
7
+ output = pipe_flan(input)
8
+ # return {"output": output[0]["generated_text"]}
9
+ return output[0]["generated_text"]
10
+
11
+ demo = gr.Interface(
12
+ fn=t5,
13
+ inputs=gr.Textbox(lines=2, placeholder="English: Translate There are many ducks. German:"),
14
+ outputs="text",
15
+ )
16
+
17
+ demo.launch(server_name="0.0.0.0", server_port=7860)
requirements.txt CHANGED
@@ -1,3 +1,4 @@
 
1
  fastapi==0.74.*
2
  requests==2.27.*
3
  sentencepiece==0.1.*
 
1
+ gradio
2
  fastapi==0.74.*
3
  requests==2.27.*
4
  sentencepiece==0.1.*