burhan112 commited on
Commit
96f001c
Β·
verified Β·
1 Parent(s): 162ab4c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -3,12 +3,11 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
3
  import torch
4
  import random
5
 
6
- # Model path and loading
7
- MODEL_PATH = "emojiFinetune"
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
- # Launch the interface
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()