SamratBarai commited on
Commit
36781d0
·
verified ·
1 Parent(s): 0dc3376

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+
4
+ # Load the model and tokenizer
5
+ model_name = "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B"
6
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
7
+ model = AutoModelForCausalLM.from_pretrained(model_name)
8
+
9
+ # Define the prediction function
10
+ def predict(input_text):
11
+ inputs = tokenizer(input_text, return_tensors="pt")
12
+ outputs = model.generate(**inputs)
13
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return response
15
+
16
+ # Create the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
20
+ outputs=gr.outputs.Textbox(label="Generated Text"),
21
+ title="DeepSeek-R1-Distill-Qwen-1.5B Text Generation",
22
+ description="Enter text and the model will generate a continuation.",
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ iface.launch()