Upload 2 files
Browse files- app.py +22 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import AutoModel, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# Load the BAGEL model and tokenizer
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("ByteDance-Seed/BAGEL-7B-MoT")
|
| 6 |
+
model = AutoModel.from_pretrained("ByteDance-Seed/BAGEL-7B-MoT")
|
| 7 |
+
|
| 8 |
+
# Define a function to generate outputs
|
| 9 |
+
def generate(prompt):
|
| 10 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 11 |
+
outputs = model.generate(**inputs)
|
| 12 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 13 |
+
|
| 14 |
+
# Create a Gradio interface
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=generate, # The function to run
|
| 17 |
+
inputs="text", # Input type (text box)
|
| 18 |
+
outputs="text" # Output type (text box)
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
# Launch the app
|
| 22 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|