RamaManna commited on
Commit
e860e58
·
verified ·
1 Parent(s): 54b525e

Upload 5 files

Browse files
Files changed (4) hide show
  1. app.py +31 -0
  2. sprites/idle.gif +0 -0
  3. sprites/jump.gif +0 -0
  4. sprites/wave.gif +0 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from PIL import Image
3
+ import os
4
+
5
+ # Mapping between text prompts and sprite animations
6
+ ANIMATIONS = {
7
+ "wave": "sprites/wave.gif",
8
+ "jump": "sprites/jump.gif",
9
+ "idle": "sprites/idle.gif",
10
+ }
11
+
12
+ def get_animation(prompt):
13
+ prompt = prompt.lower().strip()
14
+
15
+ # Pick a matching animation or fallback to idle
16
+ for keyword in ANIMATIONS:
17
+ if keyword in prompt:
18
+ return ANIMATIONS[keyword]
19
+ return ANIMATIONS["idle"]
20
+
21
+ with gr.Blocks() as demo:
22
+ gr.Markdown("# 🎮 2D Character Animator\nEnter a prompt like `wave`, `jump`, or `dance`.")
23
+ input_text = gr.Textbox(label="What should the character do?")
24
+ output_img = gr.Image(type="filepath", label="Animation")
25
+
26
+ run_btn = gr.Button("Animate!")
27
+
28
+ run_btn.click(fn=get_animation, inputs=input_text, outputs=output_img)
29
+
30
+ if __name__ == "__main__":
31
+ demo.launch()
sprites/idle.gif ADDED
sprites/jump.gif ADDED
sprites/wave.gif ADDED