Spaces:
Build error
Build error
File size: 1,260 Bytes
f1d50b1 e4b9c8b f1d50b1 e4b9c8b f1d50b1 e4b9c8b 2cf3514 f1d50b1 2cf3514 e4b9c8b b3a4deb e4b9c8b |
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 34 35 36 37 |
import streamlit as st
import numpy as np
from PIL import Image
from utils import load_model
def app(model_name):
model, processor = load_model(f"koclip/{model_name}")
st.title("Zero-shot Image Classification")
st.markdown(
"""
Some text goes in here.
"""
)
query = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
captions = st.text_input("์ฌ์ฉํ์ค ์บก์
์ ์ผํ ๋จ์๋ก ๊ตฌ๋ถํด์ ์ ์ด์ฃผ์ธ์", value="๊ณ ์์ด,๊ฐ์์ง,๋ํฐ๋๋ฌด...")
if st.button("์ง๋ฌธ (Query)"):
if query is None:
st.error("Please upload an image query.")
else:
image = Image.open(query)
inputs = processor(text=[""], images=image, return_tensors="jax", padding=True)
# vec = np.asarray(model.get_image_features(**inputs))
# ids, dists = index.knnQuery(vec, k=10)
# result_files = map(lambda id: files[id], ids)
# result_imgs, result_captions = [], []
# for file, dist in zip(result_files, dists):
# result_imgs.append(plt.imread(os.path.join(images_directory, file)))
# result_captions.append("{:s} (์ ์ฌ๋: {:.3f})".format(file, 1.0 - dist))
|