Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import random
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Choose a larger model
|
6 |
-
MODEL_NAME = "gpt2-medium"
|
7 |
MAX_NEW_TOKENS = 150
|
8 |
|
9 |
# Load the model once when the app starts
|
@@ -14,26 +14,25 @@ generator = pipeline(
|
|
14 |
torch_dtype="auto"
|
15 |
)
|
16 |
|
17 |
-
# Predefined words to check
|
18 |
SPECIAL_WORDS = [
|
19 |
-
'movie', 'excited', 'waiting', 'long', 'time', 'production', 'real', 'coded', 'digital', 'favorite',
|
20 |
-
'asking', 'doing', 'basketball', 'soccer', 'football', 'baseball', 'soup', 'food', 'burgers', 'pizza',
|
21 |
-
'fruit', 'pineapple', 'milk', 'jello', 'candy', 'rice', 'greens', 'lettuce', 'oatmeal', 'cereal',
|
22 |
-
'dogs', 'cats', 'animals', 'goats', 'sheep', 'movies', 'money', 'bank', 'account', 'keeping',
|
23 |
-
'looking', 'moving', 'boxes', 'elephants', 'movement', 'coding', 'developing', 'going', 'cruise',
|
24 |
-
'ship', 'boat', 'bahamas', 'foods', 'healthy', 'eating', 'important', 'pennsylvania', 'atlanta',
|
25 |
-
'north carolina', 'new york', 'france', 'paris', 'work', 'jobs', 'computers', 'computer', 'grocery',
|
26 |
-
'glamorous', 'version', 'truck', 'pickup', 'play', 'types', 'games', 'applications', 'quantum',
|
27 |
-
'speeds', 'advancements', 'technological', 'glimpse', 'countless', 'technology', 'future', 'walking',
|
28 |
-
'hello', 'jordan', 'season', 'superstar', 'nba', 'championship', 'leading', 'points', 'assist',
|
29 |
-
'career', 'chicago', 'scared', 'tongue', 'energy', 'disguise', 'business', 'older', 'grown', 'call',
|
30 |
-
'bills', 'garden', 'house', 'fallen', 'blossoms', 'lawn', 'love', 'forever', 'most', 'fan', 'clout',
|
31 |
-
'space', 'team', 'today', 'woke', 'work', 'relax', 'quicker', 'thicker', 'richer', 'data', 'ballet',
|
32 |
-
'dancer', 'goat', 'post', 'lebron', 'james', 'eagles', 'rockets', 'times', 'tank', 'pencil', 'watch',
|
33 |
-
'rolex', 'rappers', 'rockstar', 'rocket', 'rocks', 'tooth', 'teeth', 'pancake', 'breakfast', 'lunch',
|
34 |
-
'dinner', 'zoom', 'calling', 'talking', 'rule', 'ruler', 'rick', 'morty', 'martin', 'smith', 'wild',
|
35 |
-
'track', 'field', 'touchdown', 'basket', 'hope', 'yours', 'thank', 'olympics', 'sports', 'help',
|
36 |
-
'legal', 'law', 'firm', 'crowd', 'winner', 'winter', 'smoking', 'green', 'purple', 'blue', 'pink',
|
37 |
'orange', 'black', 'white', 'yellow', 'gold', 'weather', 'sun', 'middle', 'summer', 'heat', 'spring',
|
38 |
'travel', 'explore', 'adventure', 'journey', 'vacation', 'holiday', 'destination', 'airlines', 'flight',
|
39 |
'tickets', 'booking', 'passport', 'visa', 'customs', 'luggage', 'boarding', 'hotel', 'accommodation',
|
@@ -216,7 +215,7 @@ def process_text(input_text):
|
|
216 |
)
|
217 |
|
218 |
generated_text = generated[0]['generated_text']
|
219 |
-
generated_text = generated_text[:1000]
|
220 |
|
221 |
words = generated_text.split()
|
222 |
|
@@ -287,7 +286,12 @@ with gr.Blocks() as demo:
|
|
287 |
output_html = gr.HTML()
|
288 |
animate_button = gr.Button("Trigger Movement")
|
289 |
|
290 |
-
submit_button.click(
|
|
|
|
|
|
|
|
|
|
|
291 |
animate_button.click(trigger_movement, inputs=output_html, outputs=output_html)
|
292 |
|
293 |
# Launch the app
|
|
|
3 |
from transformers import pipeline
|
4 |
|
5 |
# Choose a larger model
|
6 |
+
MODEL_NAME = "gpt2-medium"
|
7 |
MAX_NEW_TOKENS = 150
|
8 |
|
9 |
# Load the model once when the app starts
|
|
|
14 |
torch_dtype="auto"
|
15 |
)
|
16 |
|
|
|
17 |
SPECIAL_WORDS = [
|
18 |
+
'movie', 'excited', 'waiting', 'long', 'time', 'production', 'real', 'coded', 'digital', 'favorite',
|
19 |
+
'asking', 'doing', 'basketball', 'soccer', 'football', 'baseball', 'soup', 'food', 'burgers', 'pizza',
|
20 |
+
'fruit', 'pineapple', 'milk', 'jello', 'candy', 'rice', 'greens', 'lettuce', 'oatmeal', 'cereal',
|
21 |
+
'dogs', 'cats', 'animals', 'goats', 'sheep', 'movies', 'money', 'bank', 'account', 'keeping',
|
22 |
+
'looking', 'moving', 'boxes', 'elephants', 'movement', 'coding', 'developing', 'going', 'cruise',
|
23 |
+
'ship', 'boat', 'bahamas', 'foods', 'healthy', 'eating', 'important', 'pennsylvania', 'atlanta',
|
24 |
+
'north carolina', 'new york', 'france', 'paris', 'work', 'jobs', 'computers', 'computer', 'grocery',
|
25 |
+
'glamorous', 'version', 'truck', 'pickup', 'play', 'types', 'games', 'applications', 'quantum',
|
26 |
+
'speeds', 'advancements', 'technological', 'glimpse', 'countless', 'technology', 'future', 'walking',
|
27 |
+
'hello', 'jordan', 'season', 'superstar', 'nba', 'championship', 'leading', 'points', 'assist',
|
28 |
+
'career', 'chicago', 'scared', 'tongue', 'energy', 'disguise', 'business', 'older', 'grown', 'call',
|
29 |
+
'bills', 'garden', 'house', 'fallen', 'blossoms', 'lawn', 'love', 'forever', 'most', 'fan', 'clout',
|
30 |
+
'space', 'team', 'today', 'woke', 'work', 'relax', 'quicker', 'thicker', 'richer', 'data', 'ballet',
|
31 |
+
'dancer', 'goat', 'post', 'lebron', 'james', 'eagles', 'rockets', 'times', 'tank', 'pencil', 'watch',
|
32 |
+
'rolex', 'rappers', 'rockstar', 'rocket', 'rocks', 'tooth', 'teeth', 'pancake', 'breakfast', 'lunch',
|
33 |
+
'dinner', 'zoom', 'calling', 'talking', 'rule', 'ruler', 'rick', 'morty', 'martin', 'smith', 'wild',
|
34 |
+
'track', 'field', 'touchdown', 'basket', 'hope', 'yours', 'thank', 'olympics', 'sports', 'help',
|
35 |
+
'legal', 'law', 'firm', 'crowd', 'winner', 'winter', 'smoking', 'green', 'purple', 'blue', 'pink',
|
36 |
'orange', 'black', 'white', 'yellow', 'gold', 'weather', 'sun', 'middle', 'summer', 'heat', 'spring',
|
37 |
'travel', 'explore', 'adventure', 'journey', 'vacation', 'holiday', 'destination', 'airlines', 'flight',
|
38 |
'tickets', 'booking', 'passport', 'visa', 'customs', 'luggage', 'boarding', 'hotel', 'accommodation',
|
|
|
215 |
)
|
216 |
|
217 |
generated_text = generated[0]['generated_text']
|
218 |
+
generated_text = generated_text[:1000]
|
219 |
|
220 |
words = generated_text.split()
|
221 |
|
|
|
286 |
output_html = gr.HTML()
|
287 |
animate_button = gr.Button("Trigger Movement")
|
288 |
|
289 |
+
submit_button.click(
|
290 |
+
fn=process_text,
|
291 |
+
inputs=input_text,
|
292 |
+
outputs=output_html,
|
293 |
+
show_progress=True # Enable the loading indicator
|
294 |
+
)
|
295 |
animate_button.click(trigger_movement, inputs=output_html, outputs=output_html)
|
296 |
|
297 |
# Launch the app
|