primerz commited on
Commit
6c851ea
·
verified ·
1 Parent(s): 3e3e641

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -3,10 +3,9 @@ import spaces
3
  import torch
4
  from model import ModelHandler
5
  from generator import Generator
6
- from config import Config
7
 
8
- # 1. Initialize Models Globally
9
- # Models are loaded into RAM here. The @spaces.GPU decorator moves them to VRAM on demand.
10
  print("Initializing Application...")
11
  handler = ModelHandler()
12
  handler.load_models()
@@ -21,6 +20,7 @@ def process_img(image, prompt):
21
  try:
22
  print("--- Starting Generation ---")
23
  result = gen.predict(image, prompt)
 
24
  return result
25
 
26
  except Exception as e:
@@ -44,7 +44,7 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
44
  placeholder="Leave empty for auto-captioning...",
45
  info="The trigger words 'p1x3l4rt, pixel art' are added automatically."
46
  )
47
- run_btn = gr.Button("Generat Pixel Art", variant="primary")
48
 
49
  with gr.Column():
50
  output_img = gr.Image(label="Pixel Art Result")
@@ -56,10 +56,16 @@ with gr.Blocks(title="Face To Pixel Art", theme=gr.themes.Soft()) as demo:
56
  outputs=[output_img]
57
  )
58
 
59
- # Examples (Optional: Add valid paths if you have example images)
60
- # gr.Examples(examples=["./examples/face.jpg"], inputs=[input_img])
 
 
 
 
 
 
61
 
62
- # 4. Launch
63
  if __name__ == "__main__":
64
  demo.queue(max_size=20, api_open=True)
65
  demo.launch(
 
3
  import torch
4
  from model import ModelHandler
5
  from generator import Generator
 
6
 
7
+ # 1. Initialize Models Globally (in RAM)
8
+ # ZeroGPU will move them to VRAM inside the @spaces.GPU function
9
  print("Initializing Application...")
10
  handler = ModelHandler()
11
  handler.load_models()
 
20
  try:
21
  print("--- Starting Generation ---")
22
  result = gen.predict(image, prompt)
23
+ print("--- Generation Complete ---")
24
  return result
25
 
26
  except Exception as e:
 
44
  placeholder="Leave empty for auto-captioning...",
45
  info="The trigger words 'p1x3l4rt, pixel art' are added automatically."
46
  )
47
+ run_btn = gr.Button("Generate Pixel Art", variant="primary")
48
 
49
  with gr.Column():
50
  output_img = gr.Image(label="Pixel Art Result")
 
56
  outputs=[output_img]
57
  )
58
 
59
+ gr.Examples(
60
+ examples=[
61
+ ["./examples/monalisa.jpg", "mona lisa portrait"],
62
+ ["./examples/man.jpg", "photo of a man"],
63
+ ["./examples/landscape.jpg", "a beautiful landscape"]
64
+ ],
65
+ inputs=[input_img, prompt]
66
+ )
67
 
68
+ # 4. Launch the App
69
  if __name__ == "__main__":
70
  demo.queue(max_size=20, api_open=True)
71
  demo.launch(