MaryahGreene commited on
Commit
f3223bf
·
verified ·
1 Parent(s): e621e92

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -24
app.py DELETED
@@ -1,24 +0,0 @@
1
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
- import gradio as gr
3
- import torch
4
-
5
- model = AutoModelForSequenceClassification.from_pretrained("./my-archflava-model.zip")
6
- tokenizer = AutoTokenizer.from_pretrained("./my-archflava-model.zip")
7
-
8
- # Map label numbers to string categories (customize this part!)
9
- label_map = {
10
- 0: "Spicy",
11
- 1: "Mild",
12
- 2: "Tangy",
13
- 3: "Salty"
14
- }
15
-
16
- def classify(text):
17
- inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
18
- with torch.no_grad():
19
- outputs = model(**inputs)
20
- pred = torch.argmax(outputs.logits, dim=1).item()
21
- return label_map[pred]
22
-
23
- demo = gr.Interface(fn=classify, inputs="text", outputs="text", title="What's Your Flava?")
24
- demo.launch()