C98yhou079 commited on
Commit
f7a6dca
·
verified ·
1 Parent(s): d9e029e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -1,3 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # app.py - Gradio UI using vendored tinyllava
2
  import io, requests, traceback
3
  from PIL import Image
 
1
+ import sys, subprocess, importlib
2
+
3
+ def ensure_torch():
4
+ try:
5
+ import torch
6
+ return
7
+ except Exception:
8
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "--no-cache-dir",
9
+ "torch==2.2.0+cpu", "--extra-index-url", "https://download.pytorch.org/whl/cpu"])
10
+ importlib.invalidate_caches()
11
+
12
+ ensure_torch()
13
+ # now safe to import torch and proceed
14
+ import torch
15
+
16
  # app.py - Gradio UI using vendored tinyllava
17
  import io, requests, traceback
18
  from PIL import Image