masa729406 commited on
Commit
26fbd64
Β·
1 Parent(s): af606b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -1,22 +1,31 @@
1
- !pip install transformers streamlit
 
2
 
3
- import streamlit as st
4
- from transformers import pipeline
5
- from PIL import Image
6
 
7
- pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
 
8
 
9
- st.title("Hot Dog? Or Not?")
10
 
11
- file_name = st.file_uploader("Upload a hot dog candidate image")
 
12
 
13
- if file_name is not None:
14
- col1, col2 = st.columns(2)
15
 
16
- image = Image.open(file_name)
17
- col1.image(image, use_column_width=True)
18
- predictions = pipeline(image)
 
 
 
 
 
 
 
 
19
 
20
- col2.header("Probabilities")
21
- for p in predictions:
22
- col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
 
 
 
 
4
 
5
+ def flip_text(x):
6
+ return x[::-1]
7
 
 
8
 
9
+ def flip_image(x):
10
+ return np.fliplr(x)
11
 
 
 
12
 
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("Flip text or image files using this demo.")
15
+ with gr.Tab("Flip Text"):
16
+ text_input = gr.Textbox()
17
+ text_output = gr.Textbox()
18
+ text_button = gr.Button("Flip")
19
+ with gr.Tab("Flip Image"):
20
+ with gr.Row():
21
+ image_input = gr.Image()
22
+ image_output = gr.Image()
23
+ image_button = gr.Button("Flip")
24
 
25
+ with gr.Accordion("Open for More!"):
26
+ gr.Markdown("Look at me...")
27
+
28
+ text_button.click(flip_text, inputs=text_input, outputs=text_output)
29
+ image_button.click(flip_image, inputs=image_input, outputs=image_output)
30
+
31
+ demo.launch()