Spaces:
Runtime error
Runtime error
new
Browse files- README.md +5 -5
- app.py +47 -0
- workdir/cheetah.jpg +0 -0
- workdir/lion.jpg +0 -0
- workdir/logo.png +0 -0
README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: 3.
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 1 |
---
|
| 2 |
+
title: img api
|
| 3 |
+
emoji: ⚡
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: pink
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 3.4.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def image_mod(image_path):
|
| 7 |
+
images = []
|
| 8 |
+
with Image.open(image_path) as im:
|
| 9 |
+
images.append(im.rotate(45))
|
| 10 |
+
images.append(im.rotate(90))
|
| 11 |
+
|
| 12 |
+
#files = os.listdir(os.curdir)
|
| 13 |
+
#print('local files: ',files)
|
| 14 |
+
#images[0].save("newlion.png")
|
| 15 |
+
#files = os.listdir(os.curdir)
|
| 16 |
+
#print('local files: ',files)
|
| 17 |
+
|
| 18 |
+
html = (
|
| 19 |
+
"<table border=1>"
|
| 20 |
+
"<tr><td>"
|
| 21 |
+
"<img src='file/workdir/lion.jpg' alt='image One'>"
|
| 22 |
+
"</td>"
|
| 23 |
+
"<td>"
|
| 24 |
+
"imapge caption"
|
| 25 |
+
"</td></tr>"
|
| 26 |
+
"<tr><td>"
|
| 27 |
+
"<img src='file/workdir/cheetah.jpg' alt='image One'>"
|
| 28 |
+
"</td>"
|
| 29 |
+
"<td>"
|
| 30 |
+
"imapge caption"
|
| 31 |
+
"</td></tr>"
|
| 32 |
+
"</table>"
|
| 33 |
+
)
|
| 34 |
+
|
| 35 |
+
return html, images
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
demo = gr.Interface(image_mod, "text" , ["html", gr.Gallery()],
|
| 39 |
+
allow_flagging="never",
|
| 40 |
+
examples=[
|
| 41 |
+
os.path.join(os.path.dirname(__file__), "workdir/cheetah.jpg"),
|
| 42 |
+
os.path.join(os.path.dirname(__file__), "workdir/lion.jpg"),
|
| 43 |
+
os.path.join(os.path.dirname(__file__), "workdir/logo.png")
|
| 44 |
+
])
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
demo.launch()
|
workdir/cheetah.jpg
ADDED
|
workdir/lion.jpg
ADDED
|
workdir/logo.png
ADDED
|