jayparmr commited on
Commit
04c5fb7
1 Parent(s): 1bc457e

Upload folder using huggingface_hub

Browse files
inference.py CHANGED
@@ -408,27 +408,18 @@ def img2img(task: Task):
408
  def inpaint(task: Task):
409
  prompt, _ = get_patched_prompt(task)
410
 
411
- width, height = get_intermediate_dimension(task)
412
  print({"prompts": prompt})
413
 
414
  images = inpainter.process(
415
  prompt=prompt,
416
  image_url=task.get_imageUrl(),
417
  mask_image_url=task.get_maskImageUrl(),
418
- width=width,
419
- height=height,
420
  seed=task.get_seed(),
421
  negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
422
  )
423
- if task.get_high_res_fix():
424
- images, _ = high_res.apply(
425
- prompt=prompt,
426
- negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
427
- images=images,
428
- width=task.get_width(),
429
- height=task.get_height(),
430
- steps=task.get_steps(),
431
- )
432
  generated_image_urls = upload_images(images, "_inpaint", task.get_taskId())
433
 
434
  clear_cuda()
 
408
  def inpaint(task: Task):
409
  prompt, _ = get_patched_prompt(task)
410
 
 
411
  print({"prompts": prompt})
412
 
413
  images = inpainter.process(
414
  prompt=prompt,
415
  image_url=task.get_imageUrl(),
416
  mask_image_url=task.get_maskImageUrl(),
417
+ width=task.get_width(),
418
+ height=task.get_height(),
419
  seed=task.get_seed(),
420
  negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
421
  )
422
+
 
 
 
 
 
 
 
 
423
  generated_image_urls = upload_images(images, "_inpaint", task.get_taskId())
424
 
425
  clear_cuda()
inference2.py CHANGED
@@ -58,13 +58,6 @@ def get_patched_prompt_tile_upscale(task: Task):
58
  )
59
 
60
 
61
- def get_intermediate_dimension(task: Task):
62
- if task.get_high_res_fix():
63
- return HighRes.get_intermediate_dimension(task.get_width(), task.get_height())
64
- else:
65
- return task.get_width(), task.get_height()
66
-
67
-
68
  @update_db
69
  @auto_clear_cuda_and_gc(controlnet)
70
  @slack.auto_send_alert
@@ -123,27 +116,18 @@ def inpaint(task: Task):
123
  else:
124
  prompt = [prompt] * num_return_sequences
125
 
126
- width, height = get_intermediate_dimension(task)
127
  print({"prompts": prompt})
128
 
129
  images = inpainter.process(
130
  prompt=prompt,
131
  image_url=task.get_imageUrl(),
132
  mask_image_url=task.get_maskImageUrl(),
133
- width=width,
134
- height=height,
135
  seed=task.get_seed(),
136
  negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
137
  )
138
- if task.get_high_res_fix():
139
- images, _ = high_res.apply(
140
- prompt=prompt,
141
- negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
142
- images=images,
143
- width=task.get_width(),
144
- height=task.get_height(),
145
- steps=task.get_steps(),
146
- )
147
  generated_image_urls = upload_images(images, "_inpaint", task.get_taskId())
148
 
149
  clear_cuda()
 
58
  )
59
 
60
 
 
 
 
 
 
 
 
61
  @update_db
62
  @auto_clear_cuda_and_gc(controlnet)
63
  @slack.auto_send_alert
 
116
  else:
117
  prompt = [prompt] * num_return_sequences
118
 
 
119
  print({"prompts": prompt})
120
 
121
  images = inpainter.process(
122
  prompt=prompt,
123
  image_url=task.get_imageUrl(),
124
  mask_image_url=task.get_maskImageUrl(),
125
+ width=task.get_width(),
126
+ height=task.get_height(),
127
  seed=task.get_seed(),
128
  negative_prompt=[task.get_negative_prompt()] * num_return_sequences,
129
  )
130
+
 
 
 
 
 
 
 
 
131
  generated_image_urls = upload_images(images, "_inpaint", task.get_taskId())
132
 
133
  clear_cuda()
internals/data/dataAccessor.py CHANGED
@@ -11,7 +11,7 @@ from internals.util.slack import Slack
11
 
12
  def updateSource(sourceId, userId, state):
13
  print("update source is called")
14
- url = api_endpoint() + f"/comic-crecoai/source/{sourceId}"
15
  headers = {
16
  "Content-Type": "application/json",
17
  "user-id": str(userId),
@@ -33,7 +33,12 @@ def updateSource(sourceId, userId, state):
33
 
34
  def saveGeneratedImages(sourceId, userId, has_nsfw: bool):
35
  print("save generation called")
36
- url = api_endpoint() + "/comic-crecoai/source/" + str(sourceId) + "/generatedImages"
 
 
 
 
 
37
  headers = {
38
  "Content-Type": "application/json",
39
  "user-id": str(userId),
@@ -53,7 +58,8 @@ def saveGeneratedImages(sourceId, userId, has_nsfw: bool):
53
 
54
 
55
  def getStyles() -> Optional[Dict]:
56
- url = api_endpoint() + "/comic-crecoai/style"
 
57
  try:
58
  response = requests.get(
59
  url,
@@ -64,12 +70,13 @@ def getStyles() -> Optional[Dict]:
64
  except requests.exceptions.Timeout:
65
  print("Request timed out while fetching styles")
66
  except requests.exceptions.RequestException as e:
 
67
  print(f"Error while fetching styles: {e}")
68
  return None
69
 
70
 
71
  def getCharacters(model_id: str) -> Optional[List]:
72
- url = api_endpoint() + "/comic-crecoai/model/{}".format(model_id)
73
  try:
74
  response = requests.get(url, timeout=10, headers=api_headers())
75
  response = response.json()
 
11
 
12
  def updateSource(sourceId, userId, state):
13
  print("update source is called")
14
+ url = api_endpoint() + f"/autodraft-crecoai/source/{sourceId}"
15
  headers = {
16
  "Content-Type": "application/json",
17
  "user-id": str(userId),
 
33
 
34
  def saveGeneratedImages(sourceId, userId, has_nsfw: bool):
35
  print("save generation called")
36
+ url = (
37
+ api_endpoint()
38
+ + "/autodraft-crecoai/source/"
39
+ + str(sourceId)
40
+ + "/generatedImages"
41
+ )
42
  headers = {
43
  "Content-Type": "application/json",
44
  "user-id": str(userId),
 
58
 
59
 
60
  def getStyles() -> Optional[Dict]:
61
+ url = api_endpoint() + "/autodraft-crecoai/style"
62
+ print(url)
63
  try:
64
  response = requests.get(
65
  url,
 
70
  except requests.exceptions.Timeout:
71
  print("Request timed out while fetching styles")
72
  except requests.exceptions.RequestException as e:
73
+ raise e
74
  print(f"Error while fetching styles: {e}")
75
  return None
76
 
77
 
78
  def getCharacters(model_id: str) -> Optional[List]:
79
+ url = api_endpoint() + "/autodraft-crecoai/model/{}".format(model_id)
80
  try:
81
  response = requests.get(url, timeout=10, headers=api_headers())
82
  response = response.json()
internals/util/commons.py CHANGED
@@ -101,22 +101,19 @@ def upload_images(images, processName: str, taskId: str):
101
  image.save(img_io, "JPEG", quality=100)
102
  img_io.seek(0)
103
  key = "crecoAI/{}{}_{}.png".format(taskId, processName, i)
104
- requests.post(
105
  api_endpoint()
106
- + "/comic-content/v1.0/upload/crecoai-assets-2?fileName="
107
  + "{}{}_{}.png".format(taskId, processName, i),
108
  headers=api_headers(),
109
  files={"file": ("image.png", img_io, "image/png")},
110
  )
 
111
  # t = s3.put_object(
112
  # Bucket="comic-assets", Key=key, Body=img_io.getvalue(), ACL="public-read"
113
  # )
114
  # print("uploading done to s3", key, t)
115
- imageUrls.append(
116
- "https://comic-assets.s3.ap-south-1.amazonaws.com/crecoAI/{}{}_{}.png".format(
117
- taskId, processName, i
118
- )
119
- )
120
 
121
  print({"promptImages": imageUrls})
122
 
@@ -130,17 +127,24 @@ def upload_image(image: Union[Image.Image, BytesIO], out_path):
130
  image = buffer
131
 
132
  image.seek(0)
133
- requests.post(
 
 
 
 
 
134
  api_endpoint()
135
- + "/comic-content/v1.0/upload/crecoai-assets-2?fileName="
136
  + str(out_path).replace("crecoAI/", ""),
137
  headers=api_headers(),
138
  files={"file": ("image.png", image, "image/png")},
139
  )
 
 
140
  # s3.upload_fileobj(image, "comic-assets", out_path, ExtraArgs={"ACL": "public-read"})
141
  image.close()
142
 
143
- image_url = "https://comic-assets.s3.ap-south-1.amazonaws.com/" + out_path
144
  print({"promptImages": image_url})
145
 
146
  return image_url
@@ -188,7 +192,7 @@ def pickPoses():
188
 
189
 
190
  def construct_default_s3_url(key):
191
- return "https://comic-assets.s3.ap-south-1.amazonaws.com/" + key
192
 
193
 
194
  def safe_index(array, index) -> Optional[Any]:
 
101
  image.save(img_io, "JPEG", quality=100)
102
  img_io.seek(0)
103
  key = "crecoAI/{}{}_{}.png".format(taskId, processName, i)
104
+ res = requests.post(
105
  api_endpoint()
106
+ + "/autodraft-content/v1.0/upload/crecoai-assets-2?fileName="
107
  + "{}{}_{}.png".format(taskId, processName, i),
108
  headers=api_headers(),
109
  files={"file": ("image.png", img_io, "image/png")},
110
  )
111
+ imgUrl = res.json()["imageUrl"]
112
  # t = s3.put_object(
113
  # Bucket="comic-assets", Key=key, Body=img_io.getvalue(), ACL="public-read"
114
  # )
115
  # print("uploading done to s3", key, t)
116
+ imageUrls.append(imgUrl)
 
 
 
 
117
 
118
  print({"promptImages": imageUrls})
119
 
 
127
  image = buffer
128
 
129
  image.seek(0)
130
+ print(
131
+ api_endpoint()
132
+ + "/autodraft-content/v1.0/upload/crecoai-assets-2?fileName="
133
+ + str(out_path).replace("crecoAI/", ""),
134
+ )
135
+ res = requests.post(
136
  api_endpoint()
137
+ + "/autodraft-content/v1.0/upload/crecoai-assets-2?fileName="
138
  + str(out_path).replace("crecoAI/", ""),
139
  headers=api_headers(),
140
  files={"file": ("image.png", image, "image/png")},
141
  )
142
+ print(res.text)
143
+ imgUrl = res.json()["imageUrl"]
144
  # s3.upload_fileobj(image, "comic-assets", out_path, ExtraArgs={"ACL": "public-read"})
145
  image.close()
146
 
147
+ image_url = imgUrl
148
  print({"promptImages": image_url})
149
 
150
  return image_url
 
192
 
193
 
194
  def construct_default_s3_url(key):
195
+ return "https://assets.autodraft.in/" + key
196
 
197
 
198
  def safe_index(array, index) -> Optional[Any]:
internals/util/config.py CHANGED
@@ -88,9 +88,9 @@ def api_headers():
88
 
89
  def api_endpoint():
90
  if env == "prod":
91
- return "https://prod.pratilipicomics.com"
92
  else:
93
- return "https://gamma.pratilipicomics.com"
94
 
95
 
96
  def comic_url():
 
88
 
89
  def api_endpoint():
90
  if env == "prod":
91
+ return "https://api.autodraft.in"
92
  else:
93
+ return "https://api.autodraft.in"
94
 
95
 
96
  def comic_url():