Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,19 +6,6 @@ import torch
|
|
| 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,7 +18,6 @@ DEFAULT_INPUT = "Describe in one paragraph."
|
|
| 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}
|
|
@@ -46,10 +32,10 @@ def generate(image, instruction=DEFAULT_INPUT, sampling=False, temperature=0.7,
|
|
| 46 |
global model, tokenizer
|
| 47 |
|
| 48 |
print(image)
|
| 49 |
-
image_rgb = Image.open(image).convert("RGB")
|
| 50 |
-
print(image_rgb, instruction)
|
| 51 |
|
| 52 |
-
inputs = [{"role": "user", "content": [
|
| 53 |
|
| 54 |
parameters = {
|
| 55 |
"sampling": sampling,
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
from transformers import AutoModel, AutoTokenizer
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Pre-Initialize
|
| 10 |
DEVICE = "auto"
|
| 11 |
if DEVICE == "auto":
|
|
|
|
| 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}
|
|
|
|
| 32 |
global model, tokenizer
|
| 33 |
|
| 34 |
print(image)
|
| 35 |
+
# image_rgb = Image.open(image).convert("RGB")
|
| 36 |
+
# print(image_rgb, instruction)
|
| 37 |
|
| 38 |
+
inputs = [{"role": "user", "content": [image, instruction]}]
|
| 39 |
|
| 40 |
parameters = {
|
| 41 |
"sampling": sampling,
|