dglazkov commited on
Commit
59b2fef
1 Parent(s): d6e14a4

Added app.py.

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import numpy as np
4
+ from transformers import pipeline
5
+
6
+ import torch
7
+ print(f"Is CUDA available: {torch.cuda.is_available()}")
8
+ print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
9
+
10
+ # All of this is copied from https://huggingface.co/spaces/osanseviero/i-like-flan/blob/main/app.py
11
+
12
+ pipe_ul2 = pipeline("text2text-generation", model="google/ul2", device="cuda:0")
13
+
14
+ title = "Playing with UL2 while learning HF and Gradio"
15
+ description = "Type a prompt and see what UL2 has to say."
16
+
17
+ def inference(text):
18
+ return pipe_ul2(text, max_length=100)[0]["generated_text"]
19
+
20
+ io = gr.Interface(
21
+ inference,
22
+ gr.Textbox(lines=3),
23
+ outputs=[
24
+ gr.Textbox(lines=3, label="UL2")
25
+ ],
26
+ title=title,
27
+ description=description
28
+ )
29
+ io.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cu113
2
+ torch
3
+ transformers