Spaces:
Sleeping
Sleeping
Update Gradio settings for ZeroGPU
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ login(token=hf_token)
|
|
| 11 |
|
| 12 |
# Model repository IDs
|
| 13 |
base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
|
| 14 |
-
peft_model_id = "ubiodee/Plutuslearn-Llama-3.2-3B-Instruct"
|
| 15 |
|
| 16 |
# Load the tokenizer from the fine-tuned model
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(peft_model_id, token=hf_token)
|
|
@@ -26,7 +26,7 @@ base_model = AutoModelForCausalLM.from_pretrained(
|
|
| 26 |
trust_remote_code=True
|
| 27 |
)
|
| 28 |
|
| 29 |
-
# Resize
|
| 30 |
base_model.resize_token_embeddings(len(tokenizer))
|
| 31 |
|
| 32 |
# Load the PEFT adapter
|
|
@@ -42,7 +42,7 @@ def predict(text, max_length=100):
|
|
| 42 |
except Exception as e:
|
| 43 |
return f"Error during inference: {str(e)}"
|
| 44 |
|
| 45 |
-
# Create Gradio interface
|
| 46 |
demo = gr.Interface(
|
| 47 |
fn=predict,
|
| 48 |
inputs=[
|
|
@@ -52,7 +52,8 @@ demo = gr.Interface(
|
|
| 52 |
outputs=gr.Textbox(label="Model Output"),
|
| 53 |
title="LearnPlutus Demo",
|
| 54 |
description="Test the fine-tuned Llama-3.2-3B-Instruct model on ZeroGPU.",
|
| 55 |
-
|
| 56 |
)
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
| 11 |
|
| 12 |
# Model repository IDs
|
| 13 |
base_model_id = "meta-llama/Llama-3.2-3B-Instruct"
|
| 14 |
+
peft_model_id = "ubiodee/Plutuslearn-Llama-3.2-3B-Instruct" # Replace with your model repo
|
| 15 |
|
| 16 |
# Load the tokenizer from the fine-tuned model
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained(peft_model_id, token=hf_token)
|
|
|
|
| 26 |
trust_remote_code=True
|
| 27 |
)
|
| 28 |
|
| 29 |
+
# Resize embeddings to match fine-tuned tokenizer
|
| 30 |
base_model.resize_token_embeddings(len(tokenizer))
|
| 31 |
|
| 32 |
# Load the PEFT adapter
|
|
|
|
| 42 |
except Exception as e:
|
| 43 |
return f"Error during inference: {str(e)}"
|
| 44 |
|
| 45 |
+
# Create Gradio interface
|
| 46 |
demo = gr.Interface(
|
| 47 |
fn=predict,
|
| 48 |
inputs=[
|
|
|
|
| 52 |
outputs=gr.Textbox(label="Model Output"),
|
| 53 |
title="LearnPlutus Demo",
|
| 54 |
description="Test the fine-tuned Llama-3.2-3B-Instruct model on ZeroGPU.",
|
| 55 |
+
flagging_mode="never" # Updated from allow_flagging
|
| 56 |
)
|
| 57 |
|
| 58 |
+
# Launch with ZeroGPU settings
|
| 59 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, share=False, ssr_mode=False)
|