mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-01 11:45:36 +08:00
* placeholder * changelog * added to readme * client * implement futures * utils * scripts * lint * reorg * scripts * serialization * cleanup * fns * serialize * cache * callbacks * updates * formatting * packaging * requirements * remove changelog * client * access token * formatting * deprecate * format backend * client replace * updates * moving from utils * remove code duplication * rm duplicates * simplify * galleryserializer * serializable * load serializers * fixing errors * errors * typing * tests * changelog * lint * fix lint * fixing files * formatting * type * fix type checking * changelog * changelog * Update client/python/gradio_client/client.py Co-authored-by: Lucain <lucainp@gmail.com> * formatting, tests * formatting, tests * gr.load * refactoring * refactoring' * formatting * formatting * tests * tests * fix tests * cleanup * added tests * adding scripts * formatting * address review comments * readme * serialize info * remove from changelog * version 0.0.2 released * lint * type fix * check * type issues * hf_token * update hf token * telemetry * docs, circle dependency * hf token * formatting * updates * sort * script * external * docs * formatting * fixes * scripts * requirements * fix tests * context * changes * formatting * fixes * format fix --------- Co-authored-by: Lucain <lucainp@gmail.com>
32 lines
818 B
Python
32 lines
818 B
Python
import gradio as gr
|
|
import pathlib
|
|
|
|
current_dir = pathlib.Path(__file__).parent
|
|
|
|
images = [str(current_dir / "cheetah1.jpeg"), str(current_dir / "cheetah1.jpg"), str(current_dir / "lion.jpg")]
|
|
|
|
|
|
img_classifier = gr.load(
|
|
"models/google/vit-base-patch16-224", examples=images, cache_examples=False
|
|
)
|
|
|
|
|
|
def func(img, text):
|
|
return img_classifier(img), text
|
|
|
|
|
|
using_img_classifier_as_function = gr.Interface(
|
|
func,
|
|
[gr.Image(type="filepath"), "text"],
|
|
["label", "text"],
|
|
examples=[
|
|
[str(current_dir / "cheetah1.jpeg"), None],
|
|
[str(current_dir / "cheetah1.jpg"), "cheetah"],
|
|
[str(current_dir / "lion.jpg"), "lion"],
|
|
],
|
|
cache_examples=False,
|
|
)
|
|
demo = gr.TabbedInterface([using_img_classifier_as_function, img_classifier])
|
|
|
|
if __name__ == "__main__":
|
|
demo.launch() |