File size: 747 Bytes
5eca0b2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

import sys, signal, base64, re, io, json, time
from io import BytesIO
from pathlib import Path
from typing import Dict
import subprocess
import requests
import gradio as gr
from PIL import Image

from app import MAPPER, save_run, _ensure_h

input = (
    "a graph about the choice of profession",
    "https://notepadacademy.com/wp-content/uploads/2023/08/image.png"
)

#MAPPER.process_query(input[0])
#MAPPER.process_image(input[1])


r = requests.get(input[1], stream=True, timeout=10); r.raise_for_status()
img = _ensure_h(Image.open(io.BytesIO(r.content)).convert("RGB"))


img_proc = img.copy(); MAPPER.process_image(img_proc)
toks, maps = MAPPER.get_token_similarity_maps(input[0], img_proc)

save_run(
    input[0], input[1], img, maps
)