Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
tokenizer =
|
| 6 |
-
model =
|
| 7 |
|
| 8 |
# Function to explain code
|
| 9 |
def explain_code(code_snippet):
|
|
@@ -22,8 +22,8 @@ demo = gr.Interface(
|
|
| 22 |
fn=explain_code,
|
| 23 |
inputs=gr.Textbox(lines=15, label="Paste your code here"),
|
| 24 |
outputs=gr.Textbox(label="Explanation"),
|
| 25 |
-
title="🧠 Code Explainer using
|
| 26 |
-
description="
|
| 27 |
theme="default"
|
| 28 |
)
|
| 29 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 3 |
|
| 4 |
+
# ✅ Use AutoTokenizer and AutoModel to avoid tokenizer mismatch
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("Salesforce/codet5-base")
|
| 6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("Salesforce/codet5-base")
|
| 7 |
|
| 8 |
# Function to explain code
|
| 9 |
def explain_code(code_snippet):
|
|
|
|
| 22 |
fn=explain_code,
|
| 23 |
inputs=gr.Textbox(lines=15, label="Paste your code here"),
|
| 24 |
outputs=gr.Textbox(label="Explanation"),
|
| 25 |
+
title="🧠 Code Explainer using CodeT5",
|
| 26 |
+
description="Paste your code and get a plain English explanation using Salesforce's CodeT5.",
|
| 27 |
theme="default"
|
| 28 |
)
|
| 29 |
|