jashu827 commited on
Commit
35d6df1
·
verified ·
1 Parent(s): 9b8b82f

Create app.py

Browse files

The Gradio App

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 AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
+
5
+ # Load the small model (WizardCoder-1B)
6
+ model_name = "WizardLM/WizardCoder-1B-V1.0"
7
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
8
+ model = AutoModelForCausalLM.from_pretrained(model_name).to("cpu")
9
+
10
+ def generate_manim_code(prompt):
11
+ inputs = tokenizer(prompt, return_tensors="pt").to("cpu")
12
+ outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7)
13
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
14
+ return response
15
+
16
+ description = "💡 Enter a prompt like: *Write a Manim script to animate a growing square*"
17
+
18
+ iface = gr.Interface(
19
+ fn=generate_manim_code,
20
+ inputs=gr.Textbox(label="Prompt", placeholder="e.g., Create a bouncing ball using Manim"),
21
+ outputs=gr.Textbox(label="Generated Manim Code"),
22
+ title="🎬 Manim Code Generator",
23
+ description=description
24
+ )
25
+
26
+ iface.launch()