Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,12 +3,11 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
3 |
import torch
|
4 |
import random
|
5 |
|
6 |
-
# Model path
|
7 |
-
MODEL_PATH = "
|
8 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
9 |
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH).to("cuda" if torch.cuda.is_available() else "cpu")
|
10 |
|
11 |
-
# Emoji brainpower function
|
12 |
def emojiq_brainpower():
|
13 |
logic = random.randint(40, 100)
|
14 |
emoji_confusion = 100 - logic
|
@@ -18,7 +17,6 @@ def emojiq_brainpower():
|
|
18 |
f"and {caffeine}% caffeine boost βπ"
|
19 |
)
|
20 |
|
21 |
-
# Function to solve emoji math problem
|
22 |
def solve_emoji_math(problem, temperature, max_length, top_p):
|
23 |
if not problem.strip():
|
24 |
return "β οΈ Please enter an emoji math problem to solve.", ""
|
@@ -41,31 +39,26 @@ def solve_emoji_math(problem, temperature, max_length, top_p):
|
|
41 |
|
42 |
return f"β
Solution: **{solved_text}**", brainpower
|
43 |
|
44 |
-
# Gradio interface
|
45 |
with gr.Blocks(title="EmojIQ - Emoji Math Solver") as interface:
|
46 |
gr.Markdown("# π’ EmojIQ: Emoji Math Solver")
|
47 |
gr.Markdown("### Cracking Emoji Codes, Solving Math with a Smile! πβπ")
|
48 |
gr.Markdown("Enter an emoji math problem, and let EmojIQ solve it! π€")
|
49 |
|
50 |
-
# Input section
|
51 |
problem_input = gr.Textbox(
|
52 |
label="π Emoji Math Problem",
|
53 |
placeholder="e.g., π + π + π = 12",
|
54 |
lines=3
|
55 |
)
|
56 |
|
57 |
-
# Model settings in a column
|
58 |
with gr.Row():
|
59 |
with gr.Column():
|
60 |
temperature = gr.Slider(0.0, 1.5, value=0.7, step=0.1, label="Temperature (0 = logical, 1 = creative)")
|
61 |
max_length = gr.Slider(50, 200, value=100, step=10, label="Max Output Length")
|
62 |
top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p (sampling diversity)")
|
63 |
|
64 |
-
# Output section
|
65 |
solution_output = gr.Textbox(label="Solution", interactive=False)
|
66 |
brainpower_output = gr.Textbox(label="EmojIQ Brainpower", interactive=False)
|
67 |
|
68 |
-
# Solve button
|
69 |
solve_button = gr.Button("π Solve Emoji Math")
|
70 |
solve_button.click(
|
71 |
fn=solve_emoji_math,
|
@@ -76,5 +69,4 @@ with gr.Blocks(title="EmojIQ - Emoji Math Solver") as interface:
|
|
76 |
gr.Markdown("---")
|
77 |
gr.Markdown("π’ **EmojIQ** - Cracking Emoji Codes, One Equation at a Time! π")
|
78 |
|
79 |
-
|
80 |
-
interface.launch(share=True)
|
|
|
3 |
import torch
|
4 |
import random
|
5 |
|
6 |
+
# Model path (relative to the Space root)
|
7 |
+
MODEL_PATH = "./emojIQ_deepseekmath-r1"
|
8 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
|
9 |
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH).to("cuda" if torch.cuda.is_available() else "cpu")
|
10 |
|
|
|
11 |
def emojiq_brainpower():
|
12 |
logic = random.randint(40, 100)
|
13 |
emoji_confusion = 100 - logic
|
|
|
17 |
f"and {caffeine}% caffeine boost βπ"
|
18 |
)
|
19 |
|
|
|
20 |
def solve_emoji_math(problem, temperature, max_length, top_p):
|
21 |
if not problem.strip():
|
22 |
return "β οΈ Please enter an emoji math problem to solve.", ""
|
|
|
39 |
|
40 |
return f"β
Solution: **{solved_text}**", brainpower
|
41 |
|
|
|
42 |
with gr.Blocks(title="EmojIQ - Emoji Math Solver") as interface:
|
43 |
gr.Markdown("# π’ EmojIQ: Emoji Math Solver")
|
44 |
gr.Markdown("### Cracking Emoji Codes, Solving Math with a Smile! πβπ")
|
45 |
gr.Markdown("Enter an emoji math problem, and let EmojIQ solve it! π€")
|
46 |
|
|
|
47 |
problem_input = gr.Textbox(
|
48 |
label="π Emoji Math Problem",
|
49 |
placeholder="e.g., π + π + π = 12",
|
50 |
lines=3
|
51 |
)
|
52 |
|
|
|
53 |
with gr.Row():
|
54 |
with gr.Column():
|
55 |
temperature = gr.Slider(0.0, 1.5, value=0.7, step=0.1, label="Temperature (0 = logical, 1 = creative)")
|
56 |
max_length = gr.Slider(50, 200, value=100, step=10, label="Max Output Length")
|
57 |
top_p = gr.Slider(0.0, 1.0, value=0.9, step=0.05, label="Top-p (sampling diversity)")
|
58 |
|
|
|
59 |
solution_output = gr.Textbox(label="Solution", interactive=False)
|
60 |
brainpower_output = gr.Textbox(label="EmojIQ Brainpower", interactive=False)
|
61 |
|
|
|
62 |
solve_button = gr.Button("π Solve Emoji Math")
|
63 |
solve_button.click(
|
64 |
fn=solve_emoji_math,
|
|
|
69 |
gr.Markdown("---")
|
70 |
gr.Markdown("π’ **EmojIQ** - Cracking Emoji Codes, One Equation at a Time! π")
|
71 |
|
72 |
+
interface.launch()
|
|