Spaces:
Paused
Paused
add vllm
Browse files
app.py
CHANGED
|
@@ -9,14 +9,11 @@ from huggingface_hub import login
|
|
| 9 |
import torch
|
| 10 |
import torch.nn.functional as F
|
| 11 |
import spaces
|
| 12 |
-
import json
|
| 13 |
import json
|
| 14 |
import gradio as gr
|
| 15 |
-
from PIL import Image
|
| 16 |
from huggingface_hub import snapshot_download
|
| 17 |
-
import spaces
|
| 18 |
import os
|
| 19 |
-
from loadimg import load_img
|
| 20 |
import traceback
|
| 21 |
|
| 22 |
login(os.environ.get("HUGGINGFACE_TOKEN"))
|
|
@@ -47,7 +44,6 @@ llm = LLM(model=repo_id,
|
|
| 47 |
max_num_batched_tokens=max_img_per_msg * max_tokens_per_img,
|
| 48 |
limit_mm_per_prompt={"image": max_img_per_msg})
|
| 49 |
|
| 50 |
-
|
| 51 |
def encode_image(image: Image.Image, image_format="PNG") -> str:
|
| 52 |
im_file = BytesIO()
|
| 53 |
image.save(im_file, format=image_format)
|
|
@@ -102,7 +98,7 @@ def compare_images(image1_url, image2_url, prompt, progress=gr.Progress(track_tq
|
|
| 102 |
|
| 103 |
return outputs[0].outputs[0].text
|
| 104 |
|
| 105 |
-
@spaces.GPU(
|
| 106 |
def calculate_image_similarity(image1_url, image2_url):
|
| 107 |
if llm is None:
|
| 108 |
return "Error: LLM initialization failed. Please try again later."
|
|
|
|
| 9 |
import torch
|
| 10 |
import torch.nn.functional as F
|
| 11 |
import spaces
|
|
|
|
| 12 |
import json
|
| 13 |
import gradio as gr
|
|
|
|
| 14 |
from huggingface_hub import snapshot_download
|
|
|
|
| 15 |
import os
|
| 16 |
+
# from loadimg import load_img
|
| 17 |
import traceback
|
| 18 |
|
| 19 |
login(os.environ.get("HUGGINGFACE_TOKEN"))
|
|
|
|
| 44 |
max_num_batched_tokens=max_img_per_msg * max_tokens_per_img,
|
| 45 |
limit_mm_per_prompt={"image": max_img_per_msg})
|
| 46 |
|
|
|
|
| 47 |
def encode_image(image: Image.Image, image_format="PNG") -> str:
|
| 48 |
im_file = BytesIO()
|
| 49 |
image.save(im_file, format=image_format)
|
|
|
|
| 98 |
|
| 99 |
return outputs[0].outputs[0].text
|
| 100 |
|
| 101 |
+
@spaces.GPU()
|
| 102 |
def calculate_image_similarity(image1_url, image2_url):
|
| 103 |
if llm is None:
|
| 104 |
return "Error: LLM initialization failed. Please try again later."
|