import gradio as gr from paddlenlp import Taskflow import json import numpy as np import requests import urllib from io import BytesIO from PIL import Image vision_language=Taskflow("feature_extraction", model='PaddlePaddle/ernie_vil-2.0-base-zh') def getImageTestFeture(content): if content.startswith("http"): response = requests.get(content) x=BytesIO(response.content) f_embeds = vision_language(Image.open(x)) else: f_embeds = vision_language(content) text_features = f_embeds["features"][0] text_features=text_features.tolist() return text_features def greet(name): x=getImageTestFeture(name) return x demo = gr.Interface(fn=greet, inputs="text", outputs="text") if __name__ == "__main__": demo.launch()