Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,31 +1,43 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
|
|
|
|
3 |
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
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 |
-
|
26 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#导入gradio
|
2 |
import gradio as gr
|
3 |
+
#导入transformers相关包
|
4 |
+
from transformers import *
|
5 |
|
6 |
+
# import webbrowser
|
7 |
+
# # 打开指定的URL
|
8 |
+
# webbrowser.open('http://127.0.0.1:7860')
|
9 |
|
10 |
+
#通过Interface加载pipeline并启动服务
|
11 |
+
gr.Interface.from_pipeline( pipeline("image-to-text",model="Salesforce/blip-image-captioning-base")).launch(share=True)
|
12 |
|
13 |
+
# import numpy as np
|
14 |
+
# import gradio as gr
|
15 |
|
|
|
|
|
16 |
|
17 |
+
# def flip_text(x):
|
18 |
+
# return x[::-1]
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
# def flip_image(x):
|
22 |
+
# return np.fliplr(x)
|
23 |
|
|
|
|
|
24 |
|
25 |
+
# with gr.Blocks() as demo:
|
26 |
+
# gr.Markdown("Flip text or image files using this demo.")
|
27 |
+
# with gr.Tab("Flip Text"):
|
28 |
+
# text_input = gr.Textbox()
|
29 |
+
# text_output = gr.Textbox()
|
30 |
+
# text_button = gr.Button("Flip")
|
31 |
+
# with gr.Tab("Flip Image"):
|
32 |
+
# with gr.Row():
|
33 |
+
# image_input = gr.Image()
|
34 |
+
# image_output = gr.Image()
|
35 |
+
# image_button = gr.Button("Flip")
|
36 |
+
|
37 |
+
# with gr.Accordion("Open for More!"):
|
38 |
+
# gr.Markdown("Look at me...")
|
39 |
+
|
40 |
+
# text_button.click(flip_text, inputs=text_input, outputs=text_output)
|
41 |
+
# image_button.click(flip_image, inputs=image_input, outputs=image_output)
|
42 |
+
|
43 |
+
# demo.launch(share=True)
|