Update app.py
Browse files
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
|
| 6 |
-
|
| 7 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|