Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,7 +21,7 @@ orig_clip_model, orig_clip_processor = clip.load("ViT-B/32", device=device, jit=
|
|
21 |
# Load the Unsplash dataset
|
22 |
dataset = load_dataset("jamescalam/unsplash-25k-photos", split="train") # all 25K images are in train split
|
23 |
|
24 |
-
height =
|
25 |
|
26 |
def predict(image, labels):
|
27 |
inputs = processor(text=[f"a photo of {c}" for c in labels], images=image, return_tensors="pt", padding=True)
|
@@ -107,7 +107,7 @@ def search(search_query):
|
|
107 |
|
108 |
|
109 |
|
110 |
-
with gr.Blocks(css="
|
111 |
|
112 |
with gr.Tab("Zero-Shot Classification"):
|
113 |
labels = gr.State([]) # creates hidden component that can store a value and can be used as input/output; here, initial value is an empty list
|
@@ -147,7 +147,7 @@ with gr.Blocks(css="#caption-text {font-size: 40px !important;}") as demo:
|
|
147 |
with gr.Row():
|
148 |
get_btn_cap = gr.Button("Get Random Image").style(full_width=False)
|
149 |
caption_btn = gr.Button("Create Caption").style(full_width=False)
|
150 |
-
caption = gr.Textbox(label='Caption',
|
151 |
get_btn_cap.click(fn=rand_image, outputs=im_cap)
|
152 |
#im_cap.change(generate_text, inputs=im_cap, outputs=caption)
|
153 |
caption_btn.click(generate_text, inputs=[im_cap, model_name], outputs=caption)
|
|
|
21 |
# Load the Unsplash dataset
|
22 |
dataset = load_dataset("jamescalam/unsplash-25k-photos", split="train") # all 25K images are in train split
|
23 |
|
24 |
+
height = 256 # height for resizing images
|
25 |
|
26 |
def predict(image, labels):
|
27 |
inputs = processor(text=[f"a photo of {c}" for c in labels], images=image, return_tensors="pt", padding=True)
|
|
|
107 |
|
108 |
|
109 |
|
110 |
+
with gr.Blocks(css=".caption-text {font-size: 40px !important;}") as demo:
|
111 |
|
112 |
with gr.Tab("Zero-Shot Classification"):
|
113 |
labels = gr.State([]) # creates hidden component that can store a value and can be used as input/output; here, initial value is an empty list
|
|
|
147 |
with gr.Row():
|
148 |
get_btn_cap = gr.Button("Get Random Image").style(full_width=False)
|
149 |
caption_btn = gr.Button("Create Caption").style(full_width=False)
|
150 |
+
caption = gr.Textbox(label='Caption', elem_classes="caption-text")
|
151 |
get_btn_cap.click(fn=rand_image, outputs=im_cap)
|
152 |
#im_cap.change(generate_text, inputs=im_cap, outputs=caption)
|
153 |
caption_btn.click(generate_text, inputs=[im_cap, model_name], outputs=caption)
|