Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,7 @@ from PIL import Image
|
|
| 8 |
import numpy as np
|
| 9 |
import os
|
| 10 |
import time
|
| 11 |
-
|
| 12 |
|
| 13 |
|
| 14 |
# Load model and processor
|
|
@@ -29,7 +29,7 @@ tokenizer = vl_chat_processor.tokenizer
|
|
| 29 |
cuda_device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 30 |
|
| 31 |
@torch.inference_mode()
|
| 32 |
-
|
| 33 |
# Multimodal Understanding function
|
| 34 |
def multimodal_understanding(image, question, seed, top_p, temperature):
|
| 35 |
# Clear CUDA cache before generating
|
|
@@ -132,7 +132,7 @@ def unpack(dec, width, height, parallel_size=5):
|
|
| 132 |
|
| 133 |
|
| 134 |
@torch.inference_mode()
|
| 135 |
-
|
| 136 |
def generate_image(prompt,
|
| 137 |
seed=None,
|
| 138 |
guidance=5,
|
|
|
|
| 8 |
import numpy as np
|
| 9 |
import os
|
| 10 |
import time
|
| 11 |
+
import spaces # Import spaces for ZeroGPU compatibility
|
| 12 |
|
| 13 |
|
| 14 |
# Load model and processor
|
|
|
|
| 29 |
cuda_device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 30 |
|
| 31 |
@torch.inference_mode()
|
| 32 |
+
@spaces.GPU(duration=120)
|
| 33 |
# Multimodal Understanding function
|
| 34 |
def multimodal_understanding(image, question, seed, top_p, temperature):
|
| 35 |
# Clear CUDA cache before generating
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
@torch.inference_mode()
|
| 135 |
+
@spaces.GPU(duration=120) # Specify a duration to avoid timeout
|
| 136 |
def generate_image(prompt,
|
| 137 |
seed=None,
|
| 138 |
guidance=5,
|