aashraychegu commited on
Commit
3f4fe95
·
1 Parent(s): 5381248

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -1,7 +1,8 @@
1
  import gradio as gr
2
  import os
3
  import requests
4
-
 
5
  url = "https://www.mindat.org/imagecache/46/9c/03220450016186848702713.jpg"
6
  headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
7
  "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
@@ -24,8 +25,12 @@ headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit
24
 
25
  def greet():
26
  img = requests.get(url,headers = headers).content
27
- print(img.decode("ascii"))
28
- return Image.open(BytesIO(binascii.unhexlify(img)))
 
 
 
 
29
 
30
  with gr.Blocks() as iface:
31
  btn = gr.Button("Run")
 
1
  import gradio as gr
2
  import os
3
  import requests
4
+ import binascii
5
+ from PIl import Image
6
  url = "https://www.mindat.org/imagecache/46/9c/03220450016186848702713.jpg"
7
  headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
8
  "Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
 
25
 
26
  def greet():
27
  img = requests.get(url,headers = headers).content
28
+ # print(img)
29
+ print(len(img))
30
+ os.touch("./test.jpg")
31
+ with open("./test.jpg","wb+") as f:
32
+ f.write(img)
33
+ return Image.open("./test.jpg")
34
 
35
  with gr.Blocks() as iface:
36
  btn = gr.Button("Run")