cocktailpeanut commited on
Commit
90c62ea
·
1 Parent(s): 8e698e5
Files changed (2) hide show
  1. app.py +4 -3
  2. requirements.txt +3 -3
app.py CHANGED
@@ -11,6 +11,7 @@ import torch.nn as nn
11
  import math
12
  import logging
13
  import sys
 
14
  from qwen2_vl.modeling_qwen2_vl import Qwen2VLSimplifiedModel
15
  from huggingface_hub import snapshot_download
16
 
@@ -24,7 +25,7 @@ logger = logging.getLogger(__name__)
24
 
25
  MODEL_ID = "Djrango/Qwen2vl-Flux"
26
  MODEL_CACHE_DIR = "model_cache"
27
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
28
  DTYPE = torch.bfloat16
29
 
30
  # Aspect ratio options
@@ -171,7 +172,7 @@ def process_image(image):
171
  # Move models back to CPU
172
  qwen2vl.cpu()
173
  connector.cpu()
174
- torch.cuda.empty_cache()
175
 
176
  return result
177
 
@@ -429,4 +430,4 @@ if __name__ == "__main__":
429
  server_name="0.0.0.0", # Listen on all network interfaces
430
  server_port=7860, # Use a specific port
431
  share=False, # Disable public URL sharing
432
- )
 
11
  import math
12
  import logging
13
  import sys
14
+ import devicetorch
15
  from qwen2_vl.modeling_qwen2_vl import Qwen2VLSimplifiedModel
16
  from huggingface_hub import snapshot_download
17
 
 
25
 
26
  MODEL_ID = "Djrango/Qwen2vl-Flux"
27
  MODEL_CACHE_DIR = "model_cache"
28
+ DEVICE = devictorch.get(torch)
29
  DTYPE = torch.bfloat16
30
 
31
  # Aspect ratio options
 
172
  # Move models back to CPU
173
  qwen2vl.cpu()
174
  connector.cpu()
175
+ devicetorch.empty_cache(torch)
176
 
177
  return result
178
 
 
430
  server_name="0.0.0.0", # Listen on all network interfaces
431
  server_port=7860, # Use a specific port
432
  share=False, # Disable public URL sharing
433
+ )
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  # Core dependencies
2
- torch==2.4.0
3
- torchvision==0.19.0
4
  transformers==4.45.0
5
  diffusers==0.30.0
6
  accelerate==0.33.0
@@ -12,4 +12,4 @@ numpy>=1.24.0
12
  protobuf==4.23.4
13
  sentencepiece==0.2.0
14
  gradio==5.6.0
15
- huggingface-hub
 
1
  # Core dependencies
2
+ #torch==2.4.0
3
+ #torchvision==0.19.0
4
  transformers==4.45.0
5
  diffusers==0.30.0
6
  accelerate==0.33.0
 
12
  protobuf==4.23.4
13
  sentencepiece==0.2.0
14
  gradio==5.6.0
15
+ huggingface-hub