Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoProcessor, AutoModelForSeq2SeqLM
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
# Load model
|
5 |
+
processor = AutoProcessor.from_pretrained("Alpha-VLLM/Lumina-mGPT-7B-768")
|
6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Alpha-VLLM/Lumina-mGPT-7B-768")
|
7 |
+
|
8 |
+
def generate_text(input_text):
|
9 |
+
inputs = processor(input_text, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs)
|
11 |
+
return processor.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
|
13 |
+
# Gradio Interface
|
14 |
+
iface = gr.Interface(
|
15 |
+
fn=generate_text,
|
16 |
+
inputs=gr.Textbox(label="Input Text"),
|
17 |
+
outputs=gr.Textbox(label="Generated Output"),
|
18 |
+
title="Lumina mGPT-7B-768",
|
19 |
+
description="Enter text to generate output using Lumina-mGPT-7B-768."
|
20 |
+
)
|
21 |
+
|
22 |
+
iface.launch()
|