Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Imports
|
2 |
+
import spaces
|
3 |
+
import torch
|
4 |
+
|
5 |
+
from transformers import AutoModel, AutoTokenizer
|
6 |
+
|
7 |
+
# Pre-Initialize
|
8 |
+
DEVICE = "auto"
|
9 |
+
if DEVICE == "auto":
|
10 |
+
DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
|
11 |
+
print(f"[SYSTEM] | Using {DEVICE} type compute device.")
|
12 |
+
|
13 |
+
# Variables
|
14 |
+
repo = AutoModel.from_pretrained("openbmb/MiniCPM-V-2_6", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
15 |
+
tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True)
|
16 |
+
|
17 |
+
# Functions
|
18 |
+
# Initialize
|