Caseyishere commited on
Commit
2efe8d0
·
verified ·
1 Parent(s): 500325b

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -80
app.py DELETED
@@ -1,80 +0,0 @@
1
-
2
- import streamlit as st
3
- import torch
4
- import numpy as np
5
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
6
-
7
- # Load the model and tokenizer from Hugging Face
8
- model = AutoModelForSequenceClassification.from_pretrained("Caseyishere/StoryCraft", num_labels=5)
9
- tokenizer = AutoTokenizer.from_pretrained("Caseyishere/StoryCraft")
10
-
11
- # Streamlit app interface
12
- st.set_page_config(page_title="Story Craft", page_icon="🍽️", layout="centered")
13
-
14
- # Set page title and styles
15
- st.title("🍽️ Welcome to Story Craft 🍽️")
16
- st.markdown("""
17
- <style>
18
- .big-font {
19
- font-size:24px !important;
20
- font-weight:bold;
21
- }
22
- .highlight {
23
- color: #FF4B4B;
24
- }
25
- .divider {
26
- border-top: 2px solid #bbb;
27
- margin: 20px 0;
28
- }
29
- </style>
30
- """, unsafe_allow_html=True)
31
-
32
- # Get user input
33
- user_input = st.text_input("Please tell us what you like today:")
34
-
35
- if user_input:
36
- # Preprocess the input using the tokenizer
37
- inputs = tokenizer(user_input, padding=True, truncation=True, return_tensors='pt')
38
-
39
- # Get predictions from the model
40
- outputs = model(**inputs)
41
- predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
42
- predictions = predictions.cpu().detach().numpy()
43
-
44
- # Get the predicted label
45
- predicted_label = np.argmax(predictions)
46
-
47
- # Generate response based on predicted label
48
- responses = {
49
- 0: '''Appetizer: Escargots: Snails cooked in garlic butter with herbs
50
- Main Course: Coq au vin: Chicken braised in red wine with mushrooms and onions
51
- Side Dish: Pommes frites: French fries
52
- Dessert: Crème brûlée: Custard topped with caramelized sugar
53
- Beverage: Bordeaux: A red wine from the Bordeaux region of France
54
- Cheese Course: Fromage à raclette: Melted cheese served with bread, potatoes, and pickles''',
55
- 1: '''Appetizer: Spätzle: Swabian egg noodles with cheese
56
- Main Course: Wiener schnitzel: Breaded veal cutlet
57
- Side Dish: Sauerkraut: Fermented cabbage
58
- Dessert: Schwarzwälder Kirschtorte: Black Forest cake
59
- Beverage: Kölsch: A light, golden ale from Cologne
60
- Cheese Course: Käsekuchen: German cheesecake''',
61
- 2: '''Appetizer: Creamy Spinach and Artichoke Dip with tortilla chips
62
- Main Course: Ribeye Steak cooked to your desired temperature (medium-rare, medium, well-done)
63
- Side Dish: Baked Potato topped with butter, sour cream, and bacon bits
64
- Dessert: Chocolate Lava Cake with vanilla ice cream
65
- Beverage: Red Wine (ask your server for a recommendation based on your preferences)
66
- Salad: Caesar Salad with romaine lettuce, croutons, Parmesan cheese, and Caesar dressing
67
- Soup: French Onion Soup with caramelized onions, Gruyère cheese, and croutons''',
68
- 3: "Oops! Something went wrong!"
69
- }
70
-
71
- # Display the response based on the predicted label
72
- st.markdown('<div class="divider"></div>', unsafe_allow_html=True)
73
- st.markdown(f'<div class="big-font highlight">Here is your curated menu based on your input:</div>', unsafe_allow_html=True)
74
- st.write(responses.get(predicted_label, "I'm not sure what you're asking for."))
75
-
76
- # Display the predicted label for reference
77
- st.write(f"Predicted label is {predicted_label}")
78
-
79
- # Add a separator
80
- st.markdown('<div class="divider"></div>', unsafe_allow_html=True)