umarfarzan commited on
Commit
54cdc5f
·
verified ·
1 Parent(s): f38bdd0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -64
app.py DELETED
@@ -1,64 +0,0 @@
1
- # -----------------------------
2
- # app.py
3
- # -----------------------------
4
-
5
- import gradio as gr
6
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
7
- import torch
8
- import torch.nn.functional as F
9
-
10
- # -----------------------------
11
- # Load the fine-tuned model
12
- # -----------------------------
13
- MODEL_REPO = "umarfarzan/deberta-best-clipworthiness" # replace with your HF repo
14
- tokenizer = AutoTokenizer.from_pretrained(MODEL_REPO)
15
- model = AutoModelForSequenceClassification.from_pretrained(MODEL_REPO)
16
- model.eval()
17
-
18
- # -----------------------------
19
- # Prediction function with colored output
20
- # -----------------------------
21
- def predict_viral(transcript):
22
- """
23
- Takes a transcript and predicts Viral or Not Viral
24
- """
25
- inputs = tokenizer(transcript, padding="max_length", truncation=True, max_length=512, return_tensors="pt")
26
-
27
- with torch.no_grad():
28
- logits = model(**inputs).logits
29
- probs = F.softmax(logits, dim=-1)
30
-
31
- pred_label = torch.argmax(probs, dim=1).item()
32
- pred_prob = probs[0, pred_label].item()
33
-
34
- if pred_label == 1:
35
- label_str = f"<span style='color:green;font-weight:bold;'>Viral</span> ({pred_prob*100:.2f}% confidence)"
36
- else:
37
- label_str = f"<span style='color:red;font-weight:bold;'>Not Viral</span> ({pred_prob*100:.2f}% confidence)"
38
-
39
- return label_str
40
-
41
- # -----------------------------
42
- # Gradio Interface
43
- # -----------------------------
44
- with gr.Blocks(title="Acliptic - Revolutionising The Future Of Clipping") as demo:
45
-
46
- gr.Markdown("<h1 style='text-align:center;color:#4B0082;'>Acliptic</h1>")
47
- gr.Markdown("<h3 style='text-align:center;color:#6A5ACD;'>Revolutionising The Future Of Clipping</h3>")
48
- gr.Markdown("---")
49
-
50
- with gr.Row():
51
- transcript_input = gr.Textbox(
52
- lines=10,
53
- placeholder="Paste your transcript here...",
54
- label="Transcript"
55
- )
56
-
57
- predict_btn = gr.Button("Predict Viral Potential")
58
-
59
- result_output = gr.HTML(label="Prediction")
60
-
61
- predict_btn.click(fn=predict_viral, inputs=transcript_input, outputs=result_output)
62
-
63
- # Launch the interface
64
- demo.launch()