File size: 1,237 Bytes
5b167c5
fcfc065
 
9531470
 
eb8d2bd
 
b3bea6e
 
 
 
1a209c5
b3bea6e
 
 
 
2239686
0bac597
2239686
 
0bac597
2239686
 
b3bea6e
 
5d76d29
41f6e0a
 
74872a6
ed2fa19
74872a6
cf05c5d
 
 
6cbf0f8
cf05c5d
 
 
 
 
 
74872a6
f6027b7
de84a3c
 
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
41
42
43
44
45
46
import streamlit as st
import pandas as pd
import numpy as np
import cv2
st.write(cv2.__version__)
print(cv2.__version__)


import json
import requests
API_URL = "https://api-inference.huggingface.co/models/gpt2"
headers = {"Authorization": f"Bearer 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"}
def query(payload):
    data = json.dumps(payload)
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return json.loads(response.content.decode("utf-8"))
inp = st.text_input("Query")
t = st.slider('Temperature', 1, 200, 2)
q = {
    "inputs":inp,
    "parameters":{"temperature":float(t)*0.5}
}
data = query(q)
print(data)

st.write(data[0]['generated_text'])
a = np.ones((100,100,3),np.uint8)
a[:,:,0]=255
st.image(a)
st.image("pers.png")

import requests

API_URL = "https://api-inference.huggingface.co/models/nvidia/segformer-b5-finetuned-ade-640-640"
headers = "" #{"Authorization": "Bearer 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"}

def query(filename):
    with open(filename, "rb") as f:
        data = f.read()
    response = requests.request("POST", API_URL, headers=headers, data=data)
    return json.loads(response.content.decode("utf-8"))

output = query("pers.png")
#st.write(output)
st.write(output[0])