Ashhar
commited on
Commit
•
e99e506
1
Parent(s):
600f54f
fixed cdn logic
Browse files- app.py +1 -2
- helpers/imageCdn.py +4 -5
app.py
CHANGED
@@ -304,7 +304,7 @@ def __generateImage(prompt: str):
|
|
304 |
"megapixels": "1",
|
305 |
"num_outputs": 1,
|
306 |
"aspect_ratio": "4:3",
|
307 |
-
"output_format": "
|
308 |
# "output_quality": 80,
|
309 |
"num_inference_steps": 4
|
310 |
},
|
@@ -312,7 +312,6 @@ def __generateImage(prompt: str):
|
|
312 |
)
|
313 |
if result:
|
314 |
result = result[0]
|
315 |
-
U.pprint(f"imageResult={result}")
|
316 |
return result
|
317 |
|
318 |
|
|
|
304 |
"megapixels": "1",
|
305 |
"num_outputs": 1,
|
306 |
"aspect_ratio": "4:3",
|
307 |
+
"output_format": "webp",
|
308 |
# "output_quality": 80,
|
309 |
"num_inference_steps": 4
|
310 |
},
|
|
|
312 |
)
|
313 |
if result:
|
314 |
result = result[0]
|
|
|
315 |
return result
|
316 |
|
317 |
|
helpers/imageCdn.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import cloudinary
|
2 |
from cloudinary import CloudinaryImage
|
3 |
import cloudinary.uploader
|
@@ -10,14 +11,12 @@ def initCloudinary():
|
|
10 |
U.pprint("Cloudinary initialized")
|
11 |
|
12 |
|
13 |
-
def __getImageId(
|
14 |
-
|
15 |
-
parts = imagePath.split('/')
|
16 |
-
return parts[-2]
|
17 |
|
18 |
|
19 |
def getCdnUrl(imagePath: str) -> str:
|
20 |
-
imageId = __getImageId(
|
21 |
cloudinary.uploader.upload(imagePath, public_id=imageId, unique_filename=False, overwrite=True)
|
22 |
U.pprint(f"Image uploaded to CDN: {imageId}")
|
23 |
srcURL = CloudinaryImage(imageId).build_url()
|
|
|
1 |
+
import uuid
|
2 |
import cloudinary
|
3 |
from cloudinary import CloudinaryImage
|
4 |
import cloudinary.uploader
|
|
|
11 |
U.pprint("Cloudinary initialized")
|
12 |
|
13 |
|
14 |
+
def __getImageId():
|
15 |
+
return uuid.uuid4()
|
|
|
|
|
16 |
|
17 |
|
18 |
def getCdnUrl(imagePath: str) -> str:
|
19 |
+
imageId = __getImageId()
|
20 |
cloudinary.uploader.upload(imagePath, public_id=imageId, unique_filename=False, overwrite=True)
|
21 |
U.pprint(f"Image uploaded to CDN: {imageId}")
|
22 |
srcURL = CloudinaryImage(imageId).build_url()
|