Aabbhishekk commited on
Commit
cd3429d
·
1 Parent(s): 42af165

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -44
app.py CHANGED
@@ -2,10 +2,19 @@
2
  import requests
3
  import gradio as gr
4
  from PIL import Image
5
- import io
 
 
6
 
 
 
 
 
 
7
  API_URL = "https://api-inference.huggingface.co/models/playgroundai/playground-v2-1024px-aesthetic"
8
- headers = {"Authorization": "Bearer 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"}
 
 
9
 
10
  def query(payload):
11
  response = requests.post(API_URL, headers=headers, json=payload)
@@ -15,50 +24,8 @@ def query(payload):
15
  image = Image.open(io.BytesIO(image_bytes))
16
  return image
17
 
18
- # user_input = "a man on the mars"
19
- # image_bytes = query({
20
- # "inputs": user_input,
21
- # })
22
-
23
-
24
- # print(image_bytes)
25
-
26
-
27
-
28
- # demo = gr.Interface(fn=query, inputs="text", outputs="image")
29
-
30
-
31
- # # You can access the image with PIL.Image for example
32
- # import io
33
- # from PIL import Image
34
- # image = Image.open(io.BytesIO(image_bytes))
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
- # import numpy as np
45
-
46
-
47
- # def sepia(input_img):
48
- # sepia_filter = np.array([
49
- # [0.393, 0.769, 0.189],
50
- # [0.349, 0.686, 0.168],
51
- # [0.272, 0.534, 0.131]
52
- # ])
53
- # sepia_img = input_img.dot(sepia_filter.T)
54
- # sepia_img /= sepia_img.max()
55
- # return sepia_img
56
 
57
- # demo = gr.Interface(image, gr.Image(), "image")
58
- # demo.launch()
59
- # demo = gr.Image(image)
60
 
61
- # demo.launch()
62
  with gr.Blocks() as demo:
63
  gr.Interface(fn=query, inputs="text", outputs="image")
64
 
 
2
  import requests
3
  import gradio as gr
4
  from PIL import Image
5
+ # from dotenv import load_dotenv
6
+ import os
7
+ token = os.environ['HF_TOKEN']
8
 
9
+
10
+
11
+ # load_dotenv()
12
+ # token = os.environ.get("HF_TOKEN", "")
13
+ # print(token)
14
  API_URL = "https://api-inference.huggingface.co/models/playgroundai/playground-v2-1024px-aesthetic"
15
+
16
+ # token =
17
+ headers = {"Authorization": "Bearer {token}"}
18
 
19
  def query(payload):
20
  response = requests.post(API_URL, headers=headers, json=payload)
 
24
  image = Image.open(io.BytesIO(image_bytes))
25
  return image
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
 
 
 
28
 
 
29
  with gr.Blocks() as demo:
30
  gr.Interface(fn=query, inputs="text", outputs="image")
31