Bils commited on
Commit
8197187
·
verified ·
1 Parent(s): b5da3d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoConfig, AutoModelForCausalLM
4
  from janus.models import MultiModalityCausalLM, VLChatProcessor
5
  from PIL import Image
6
  import numpy as np
7
- import spaces # Import spaces for ZeroGPU compatibility
8
 
9
  # Load the model and processor
10
  model_path = "deepseek-ai/Janus-Pro-7B"
@@ -63,7 +63,8 @@ def generate(input_ids, width, height, cfg_weight=5, temperature=1.0, parallel_s
63
  return patches
64
 
65
  def unpack(patches, width, height, parallel_size=5):
66
- patches = patches.to(torch.float32).cpu().numpy().transpose(0, 2, 3, 1)
 
67
  patches = np.clip((patches + 1) / 2 * 255, 0, 255)
68
 
69
  images = [Image.fromarray(patches[i].astype(np.uint8)) for i in range(parallel_size)]
@@ -128,5 +129,20 @@ def create_interface():
128
 
129
  return demo
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  demo = create_interface()
132
  demo.launch(share=True)
 
4
  from janus.models import MultiModalityCausalLM, VLChatProcessor
5
  from PIL import Image
6
  import numpy as np
7
+ import spaces
8
 
9
  # Load the model and processor
10
  model_path = "deepseek-ai/Janus-Pro-7B"
 
63
  return patches
64
 
65
  def unpack(patches, width, height, parallel_size=5):
66
+ # Detach the tensor before converting to numpy
67
+ patches = patches.detach().to(torch.float32).cpu().numpy().transpose(0, 2, 3, 1)
68
  patches = np.clip((patches + 1) / 2 * 255, 0, 255)
69
 
70
  images = [Image.fromarray(patches[i].astype(np.uint8)) for i in range(parallel_size)]
 
129
 
130
  return demo
131
 
132
+ # Footer
133
+ gr.Markdown("""
134
+ <hr>
135
+ <p style="text-align: center; font-size: 0.9em;">
136
+ Created with ❤️ by <a href="https://bilsimaging.com" target="_blank">bilsimaging.com</a>
137
+ </p>
138
+ """)
139
+
140
+ # Visitor Badge
141
+ gr.HTML("""
142
+ <a href="https://visitorbadge.io/status?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FBils%2Fradiogold">
143
+ <img src="https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fhuggingface.co%2Fspaces%2FBils%2Fradiogold&countColor=%23263759" />
144
+ </a>
145
+ """)
146
+
147
  demo = create_interface()
148
  demo.launch(share=True)