zenafey commited on
Commit
d43019a
1 Parent(s): 1cde335

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -12,8 +12,7 @@ class Prodia:
12
  def __init__(self, api_key, base=None):
13
  self.base = base or "https://api.prodia.com/v2"
14
  self.headers = {
15
- "X-Prodia-Key": api_key,
16
- "Authorization": f"Bearer {os.getenv('API_KEY')}"
17
  }
18
 
19
  def generate(self, params):
@@ -43,15 +42,18 @@ class Prodia:
43
 
44
 
45
  def generate_v2(self, config):
46
- response = self._post("https://inference.prodia.com/v2/job", {"type": "v2.job.sdxl.txt2img", "config": config})
47
  return Image.open(BytesIO(r.content)).convert("RGBA")
48
 
49
 
50
- def _post(self, url, params):
51
  headers = {
52
  **self.headers,
53
  "Content-Type": "application/json"
54
  }
 
 
 
55
  response = requests.post(url, headers=headers, data=json.dumps(params))
56
 
57
  if response.status_code != 200:
 
12
  def __init__(self, api_key, base=None):
13
  self.base = base or "https://api.prodia.com/v2"
14
  self.headers = {
15
+ "X-Prodia-Key": api_key
 
16
  }
17
 
18
  def generate(self, params):
 
42
 
43
 
44
  def generate_v2(self, config):
45
+ response = self._post("https://inference.prodia.com/v2/job", {"type": "v2.job.sdxl.txt2img", "config": config}, v2=True)
46
  return Image.open(BytesIO(r.content)).convert("RGBA")
47
 
48
 
49
+ def _post(self, url, params, v2=False):
50
  headers = {
51
  **self.headers,
52
  "Content-Type": "application/json"
53
  }
54
+ if v2:
55
+ headers['Authorization'] = f"Bearer {os.getenv('API_KEY')}"
56
+
57
  response = requests.post(url, headers=headers, data=json.dumps(params))
58
 
59
  if response.status_code != 200: