Canstralian commited on
Commit
0877721
·
verified ·
1 Parent(s): 2a5d213

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -24
app.py CHANGED
@@ -1,27 +1,7 @@
1
  import gradio as gr
2
- from transformers import AutoModelForCausalLM, AutoTokenizer
3
- import torch
4
 
5
- # Load the Unsloth Phi-4 GGUF model and tokenizer
6
- model_name = "unsloth/phi-4-gguf"
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
- model = AutoModelForCausalLM.from_pretrained(model_name)
9
 
10
- # Function to generate code based on user input
11
- def generate_code(prompt):
12
- inputs = tokenizer(prompt, return_tensors="pt")
13
- outputs = model.generate(**inputs, max_length=150)
14
- generated_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
15
- return generated_code
16
-
17
- # Gradio interface
18
- interface = gr.Interface(
19
- fn=generate_code,
20
- inputs=gr.Textbox(lines=5, label="Prompt"),
21
- outputs=gr.Code(language="python", label="Generated Code"),
22
- title="Code Generator with Unsloth Phi-4 GGUF",
23
- description="Enter a prompt to generate Python code using the Unsloth Phi-4 GGUF model."
24
- )
25
-
26
- if __name__ == "__main__":
27
- interface.launch()
 
1
  import gradio as gr
 
 
2
 
3
+ # Load the model from Hugging Face
4
+ demo = gr.load("models/unsloth/phi-4-GGUF")
 
 
5
 
6
+ # Launch the Gradio interface
7
+ demo.launch()