Spaces:
Running
Running
Andrei Zhytkevich
commited on
Commit
·
6671e18
1
Parent(s):
7f1fd36
add initial gradio application
Browse files- README.md +19 -1
- images.py +20 -0
- requirements.txt +3 -0
README.md
CHANGED
@@ -1,2 +1,20 @@
|
|
1 |
# png-params
|
2 |
-
This is Gradio project for reading and displaying an image and its metadata from url
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
# png-params
|
2 |
+
This is Gradio project for reading and displaying an image and its metadata from url.
|
3 |
+
|
4 |
+
## Pre-requisites
|
5 |
+
Python 3
|
6 |
+
|
7 |
+
## Running locally
|
8 |
+
|
9 |
+
### Install requirements
|
10 |
+
``` bash
|
11 |
+
pip install -r requirements.txt
|
12 |
+
```
|
13 |
+
|
14 |
+
### Run
|
15 |
+
``` bash
|
16 |
+
python images.py
|
17 |
+
```
|
18 |
+
|
19 |
+
### Open UI
|
20 |
+
Usually Gradio UI is running on http://127.0.0.1:7860
|
images.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from PIL import Image
|
3 |
+
from urllib.request import Request, urlopen
|
4 |
+
|
5 |
+
def display_image_from_url(url):
|
6 |
+
if url == '':
|
7 |
+
return None, ""
|
8 |
+
|
9 |
+
req = Request(
|
10 |
+
url=url,
|
11 |
+
headers={'User-Agent': 'Mozilla/5.0'}
|
12 |
+
)
|
13 |
+
res = urlopen(req)
|
14 |
+
image = Image.open(res)
|
15 |
+
image.load()
|
16 |
+
|
17 |
+
return image, image.info
|
18 |
+
|
19 |
+
server = gr.Interface(display_image_from_url, "text", ["image", "text"])
|
20 |
+
server.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
Pillow
|
2 |
+
gradio
|
3 |
+
urllib3
|