Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,7 @@ from io import BytesIO
|
|
19 |
import datetime
|
20 |
import pytz
|
21 |
import csv
|
|
|
22 |
from io import StringIO
|
23 |
from huggingface_hub import (
|
24 |
create_repo,
|
@@ -467,12 +468,16 @@ def post(judul, kontent, gambar, endpoint,endpoint_media,username,password,tags,
|
|
467 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
468 |
headers = {"Authorization": f"Basic {credentials}"}
|
469 |
|
|
|
|
|
|
|
|
|
470 |
data = {
|
471 |
"alt_text": judul,
|
472 |
"media_type": "image",
|
473 |
"mime_type": "png"
|
474 |
}
|
475 |
-
files = {"file": ("image.jpg",
|
476 |
try :
|
477 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
478 |
|
|
|
19 |
import datetime
|
20 |
import pytz
|
21 |
import csv
|
22 |
+
import cv2
|
23 |
from io import StringIO
|
24 |
from huggingface_hub import (
|
25 |
create_repo,
|
|
|
468 |
credentials = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode("utf-8")
|
469 |
headers = {"Authorization": f"Basic {credentials}"}
|
470 |
|
471 |
+
cv2.imwrite('gambar.png', gambar)
|
472 |
+
gambar = cv2.imread('gambar.png')
|
473 |
+
gambar_base64 = base64.b64encode(cv2.imencode('.png', gambar)[1]).decode('utf-8')
|
474 |
+
|
475 |
data = {
|
476 |
"alt_text": judul,
|
477 |
"media_type": "image",
|
478 |
"mime_type": "png"
|
479 |
}
|
480 |
+
files = {"file": ("image.jpg", gambar_base64)}
|
481 |
try :
|
482 |
response_media= requests.post(endpoint_media, headers=headers, data=data, files=files) # Send
|
483 |
|