tonyassi commited on
Commit
dca2474
1 Parent(s): 8293635

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -5,20 +5,28 @@ import io
5
  from PIL import Image
6
  import os
7
 
8
- API_URL = "https://api-inference.huggingface.co/models/tonyassi/tony-assi-lora-1"
9
- headers = {"Authorization": "Bearer " + os.environ.get('TOKEN')}
 
 
 
10
 
11
  def query(payload):
12
  response = requests.post(API_URL, headers=headers, json=payload)
13
  return response.content
14
 
15
  def generate(prompt):
 
16
  image_bytes = query({
17
  "inputs": "Tony Assi style " + prompt,
18
  "parameters" : { "negative_prompt": "ugly, deformed, bad quality",
19
  "seed": random.randint(0,9999999)}
20
  })
21
  image = Image.open(io.BytesIO(image_bytes))
 
 
 
 
22
  return image
23
 
24
  theme = gr.themes.Base(
 
5
  from PIL import Image
6
  import os
7
 
8
+
9
+ from huggingface_hub import InferenceClient
10
+ client = InferenceClient("tonyassi/tony-assi-lora-1", token=os.environ.get('TOKEN'))
11
+
12
+
13
 
14
  def query(payload):
15
  response = requests.post(API_URL, headers=headers, json=payload)
16
  return response.content
17
 
18
  def generate(prompt):
19
+ """
20
  image_bytes = query({
21
  "inputs": "Tony Assi style " + prompt,
22
  "parameters" : { "negative_prompt": "ugly, deformed, bad quality",
23
  "seed": random.randint(0,9999999)}
24
  })
25
  image = Image.open(io.BytesIO(image_bytes))
26
+ """
27
+
28
+ # output is a PIL.Image object
29
+ image = client.text_to_image(prompt)
30
  return image
31
 
32
  theme = gr.themes.Base(