File size: 652 Bytes
b2c2198
5ddf50c
b2c2198
5ddf50c
 
26cbfcd
b2c2198
 
 
 
 
 
 
26cbfcd
 
5ddf50c
7db14ed
 
26cbfcd
 
 
 
 
 
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
import numpy as np
import streamlit as st
from transformers import CLIPProcessor, FlaxCLIPModel


def get_image(text):
    model = FlaxCLIPModel.from_pretrained("flax-community/clip-rsicd-v2")
    processor = CLIPProcessor.from_pretrained("openai/clip-vit-base-patch32")

    inputs = processor(text=[text], image=None, return_tensors="jax", padding=True)

    vector = model.get_text_features(**inputs)
    vector = np.asarray(vector)


def app():
    st.title("Welcome to Space Vector")
    st.text("You want search an image with given text.")

    text = st.text_input("Enter text: ")

    if st.button("Search"):
        st.image(get_image(text))