Spaces:
Running
on
Zero
Running
on
Zero
Staticaliza
commited on
Commit
•
baefccb
1
Parent(s):
85808d8
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,19 @@ import torch
|
|
6 |
from PIL import Image
|
7 |
from transformers import AutoModel, AutoTokenizer
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Pre-Initialize
|
10 |
DEVICE = "auto"
|
11 |
if DEVICE == "auto":
|
@@ -18,6 +31,7 @@ DEFAULT_INPUT = "Describe in one paragraph."
|
|
18 |
repo = AutoModel.from_pretrained("openbmb/MiniCPM-V-2_6", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
19 |
tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True)
|
20 |
|
|
|
21 |
css = '''
|
22 |
.gradio-container{max-width: 560px !important}
|
23 |
h1{text-align:center}
|
@@ -30,7 +44,8 @@ footer {
|
|
30 |
@spaces.GPU(duration=60)
|
31 |
def generate(image, instruction=DEFAULT_INPUT, sampling=False, temperature=0.7, top_p=0.8, top_k=100, repetition_penalty=1.05, max_tokens=512):
|
32 |
global model, tokenizer
|
33 |
-
|
|
|
34 |
image_rgb = Image.open(image).convert("RGB")
|
35 |
print(image_rgb, instruction)
|
36 |
|
|
|
6 |
from PIL import Image
|
7 |
from transformers import AutoModel, AutoTokenizer
|
8 |
|
9 |
+
|
10 |
+
import argparse
|
11 |
+
from decord import VideoReader, cpu
|
12 |
+
import io
|
13 |
+
import os
|
14 |
+
import copy
|
15 |
+
import requests
|
16 |
+
import base64
|
17 |
+
import json
|
18 |
+
import traceback
|
19 |
+
import re
|
20 |
+
import modelscope_studio as mgr
|
21 |
+
|
22 |
# Pre-Initialize
|
23 |
DEVICE = "auto"
|
24 |
if DEVICE == "auto":
|
|
|
31 |
repo = AutoModel.from_pretrained("openbmb/MiniCPM-V-2_6", torch_dtype=torch.bfloat16, trust_remote_code=True)
|
32 |
tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM-V-2_6", trust_remote_code=True)
|
33 |
|
34 |
+
repo.eval()
|
35 |
css = '''
|
36 |
.gradio-container{max-width: 560px !important}
|
37 |
h1{text-align:center}
|
|
|
44 |
@spaces.GPU(duration=60)
|
45 |
def generate(image, instruction=DEFAULT_INPUT, sampling=False, temperature=0.7, top_p=0.8, top_k=100, repetition_penalty=1.05, max_tokens=512):
|
46 |
global model, tokenizer
|
47 |
+
|
48 |
+
print(image)
|
49 |
image_rgb = Image.open(image).convert("RGB")
|
50 |
print(image_rgb, instruction)
|
51 |
|