File size: 1,686 Bytes
4c3fd3a
 
777771f
3f4fe95
c0c8825
b493477
2fde56e
aed8175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2fde56e
1ee35dc
9c87c9c
3f4fe95
 
 
 
 
4c3fd3a
1ee35dc
 
40d5ea1
9c87c9c
1ee35dc
4c3fd3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gradio as gr
import os
import requests
import binascii
from PIL import Image

url = "https://www.mindat.org/imagecache/46/9c/03220450016186848702713.jpg"
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',
            "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",
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "en-US,en;q=0.9",
            "Cache-Control": "max-age=0",
            "Cookie": """mindat=n5e0bck7vvnn6e0o9tkb49fs75; cf_clearance=PMEAfGmJF_UGxZYgB2jsRx5KsiZyNf2plDbXs4HoN5I-1703800389-0-2-d8c97f25.71e5db39.8fc820c5-0.2.1703800389""",
            "Dnt": """1""",
            "If-Modified-Since": """Sat, 17 Apr 2021 18:41:12 GMT""",
            "If-None-Match": "607b2bc8-956c4",
            "Prefer": "safe",
            "Sec-Ch-Ua": r'"Not_A Brand";v="8", "Chromium";v="120", "Microsoft Edge";v="120"',
            "Sec-Ch-Ua-Mobile": "?0",
            "Sec-Ch-Ua-Platform": '"Windows"',
            "Sec-Fetch-Dest": "document",
            "Sec-Fetch-Mode": "navigate",
            "Sec-Fetch-Site": "none",
            "Sec-Fetch-User": "?1",
            "Upgrade-Insecure-Requests": "1",}

def greet():
    img = requests.get(url,headers = headers).content
    # print(img)
    print(len(img))
    with open("./test.jpg","wb+") as f:
        f.write(img)
    return Image.open("./test.jpg")

with gr.Blocks() as iface:
    btn = gr.Button("Run")
    img = gr.Image(type = "pil")
    btn.click(fn=greet,outputs = [img])
    
iface.launch()