Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -5,7 +5,7 @@ import api_module as mj
|
|
| 5 |
import random
|
| 6 |
from io import BytesIO
|
| 7 |
import openai
|
| 8 |
-
from transparent_background import Remover
|
| 9 |
import requests
|
| 10 |
from PIL import Image
|
| 11 |
from qiniu import Auth, put_data, etag, Zone
|
|
@@ -97,28 +97,28 @@ def avatar_create(text):
|
|
| 97 |
raise SystemExit('Imagine process failed')
|
| 98 |
return task_id
|
| 99 |
|
| 100 |
-
def avatar_remove_background(image_url):
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
def avatar_upscale(task_id, index):
|
| 124 |
task_id = mj.make_upscale_request(mj_api_key, task_id, index)
|
|
|
|
| 5 |
import random
|
| 6 |
from io import BytesIO
|
| 7 |
import openai
|
| 8 |
+
#from transparent_background import Remover
|
| 9 |
import requests
|
| 10 |
from PIL import Image
|
| 11 |
from qiniu import Auth, put_data, etag, Zone
|
|
|
|
| 97 |
raise SystemExit('Imagine process failed')
|
| 98 |
return task_id
|
| 99 |
|
| 100 |
+
# def avatar_remove_background(image_url):
|
| 101 |
+
# remover = Remover() # default settings
|
| 102 |
+
# # downlaod image
|
| 103 |
+
# response = requests.get(image_url)
|
| 104 |
+
# # convert to PIL image
|
| 105 |
+
# img = Image.open(BytesIO(response.content)).convert('RGB')
|
| 106 |
+
# # remove background
|
| 107 |
+
# out = remover.process(img, type='rgba')
|
| 108 |
+
# image_io = BytesIO()
|
| 109 |
+
# Image.fromarray(out).save(image_io, format='PNG')
|
| 110 |
+
# image_data = image_io.getvalue()
|
| 111 |
+
|
| 112 |
+
# # Upload the image data
|
| 113 |
+
# q = Auth(access_key, secret_key)
|
| 114 |
+
# token = q.upload_token(bucket_name)
|
| 115 |
+
# ret, info = put_data(token, None, image_data, mime_type="image/png")
|
| 116 |
+
# if info.status_code == 200:
|
| 117 |
+
# cdn_url = 'http://image1.juramaia.com/' + ret['key']
|
| 118 |
+
# return cdn_url
|
| 119 |
+
# else:
|
| 120 |
+
# print('Failed to upload image to CDN')
|
| 121 |
+
# return None
|
| 122 |
|
| 123 |
def avatar_upscale(task_id, index):
|
| 124 |
task_id = mj.make_upscale_request(mj_api_key, task_id, index)
|