andzhk commited on
Commit
b014b6e
1 Parent(s): 18bd2aa

restructure, limit image height

Browse files
Files changed (2) hide show
  1. README.md +19 -4
  2. app.py +25 -3
README.md CHANGED
@@ -10,11 +10,16 @@ pinned: false
10
  license: wtfpl
11
  ---
12
 
13
- # PNG Parameters Viewer (png-params)
14
- [GitHub](https://github.com/andzhik/png-params)
 
 
15
  This is Gradio project for reading and displaying an image and its metadata from url.
16
 
 
 
17
  ## Usage
 
18
  - Copy image address
19
  - Paste it into the **url** field
20
  - or Drag and Drop/Upload image
@@ -25,17 +30,27 @@ This is Gradio project for reading and displaying an image and its metadata from
25
  ## Running locally
26
 
27
  ### Prerequisites
 
28
  Python 3
29
 
30
  ### Install requirements
31
- ``` bash
 
32
  pip install -r requirements.txt
33
  ```
34
 
35
  ### Run
36
- ``` bash
 
37
  python images.py
38
  ```
39
 
 
 
 
 
 
 
40
  ### Open UI
 
41
  Usually Gradio UI is running on http://127.0.0.1:7860
 
10
  license: wtfpl
11
  ---
12
 
13
+ This project is published on [HuggingFace](https://huggingface.co/spaces/andzhk/PNGInfo)
14
+
15
+ # PNG Info (png-params)
16
+
17
  This is Gradio project for reading and displaying an image and its metadata from url.
18
 
19
+ Currently, only PNG is supported.
20
+
21
  ## Usage
22
+
23
  - Copy image address
24
  - Paste it into the **url** field
25
  - or Drag and Drop/Upload image
 
30
  ## Running locally
31
 
32
  ### Prerequisites
33
+
34
  Python 3
35
 
36
  ### Install requirements
37
+
38
+ ```bash
39
  pip install -r requirements.txt
40
  ```
41
 
42
  ### Run
43
+
44
+ ```bash
45
  python images.py
46
  ```
47
 
48
+ Use [nodemon](https://www.npmjs.com/package/nodemon) for development.
49
+
50
+ ```bash
51
+ nodemon images.py
52
+ ```
53
+
54
  ### Open UI
55
+
56
  Usually Gradio UI is running on http://127.0.0.1:7860
app.py CHANGED
@@ -20,11 +20,33 @@ def display_image_from_url(url, input_image):
20
  if input_image is not None:
21
  image = input_image
22
 
23
- parameters = "Parameters have been erased from this image"
24
  if 'parameters' in image.info:
25
  parameters = image.info['parameters']
26
 
27
  return image, parameters, image.info
28
 
29
- server = gr.Interface(display_image_from_url, ["text", gr.Image(type='pil')], [gr.Image(type='pil'), gr.Textbox(label="Generation Parameters"), gr.Textbox(label="Metadata")])
30
- server.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  if input_image is not None:
21
  image = input_image
22
 
23
+ parameters = "Parameters have been erased from this image or unsupported format"
24
  if 'parameters' in image.info:
25
  parameters = image.info['parameters']
26
 
27
  return image, parameters, image.info
28
 
29
+ blocks = gr.Blocks(css="#out_image {height: 400px}")
30
+ with blocks as png_info:
31
+ with gr.Row():
32
+ gr.Markdown(
33
+ """
34
+ Report any issues on the (GitHub)[https://github.com/andzhik/png-params] page of this project
35
+ """)
36
+ with gr.Row().style(equal_height=False):
37
+ with gr.Column():
38
+ in_url = gr.Textbox(label="Source URL")
39
+ in_image = gr.Image(label="Source Image", type='pil')
40
+ with gr.Row():
41
+ btn_submit = gr.Button("Submit", variant="primary")
42
+
43
+ with gr.Column():
44
+ out_image = gr.Image(type='pil', elem_id="out_image")
45
+ out_info = gr.Textbox(label="Generation Parameters")
46
+ out_meta = gr.Textbox(label="Metadata")
47
+
48
+ btn_submit.click(fn=display_image_from_url,
49
+ inputs=[in_url, in_image],
50
+ outputs=[out_image, out_info, out_meta])
51
+
52
+ png_info.launch()