Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -417,19 +417,19 @@ def artikel_processing(link_scrap,backlink,keyword,models,api_key,azure_api_base
|
|
| 417 |
image_data= base64_string
|
| 418 |
os.remove(tmp_path)
|
| 419 |
|
| 420 |
-
output_image_io = io.BytesIO()
|
| 421 |
-
image.save(output_image_io, format='PNG')
|
| 422 |
-
output_image_io.seek(0)
|
| 423 |
|
| 424 |
-
# Upload gambar ke repo Hugging Face
|
| 425 |
-
repo_name = get_full_repo_name(model_id="Article_Gen3", token="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")
|
| 426 |
-
file_url = upload_file(
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
| 431 |
-
|
| 432 |
-
)
|
| 433 |
|
| 434 |
except:
|
| 435 |
image = Image.open('botika_logo.jpeg')
|
|
@@ -505,9 +505,10 @@ def scrap(link_scrap,backlink,keyword,version,api_key,azure_api_base,replicate_k
|
|
| 505 |
if kontent:
|
| 506 |
status = "<h3>Berhasil Generate Artikel</h3>"
|
| 507 |
time.sleep(60)
|
| 508 |
-
return status
|
| 509 |
except:
|
| 510 |
status = "<h3>Gagal Generate Artikel</h3>"
|
|
|
|
| 511 |
return status
|
| 512 |
|
| 513 |
|
|
@@ -622,22 +623,21 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
| 622 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", type="password",label="Replicate Key")
|
| 623 |
button_scrap = gr.Button("Scrap Article")
|
| 624 |
status = gr.HTML("")
|
| 625 |
-
|
|
|
|
| 626 |
view_outputs = gr.Button("View Output")
|
| 627 |
with gr.Tab("Raw Output"):
|
| 628 |
title = gr.Textbox("", label="Judul", interactive=True)
|
| 629 |
-
img = gr.Image(height=300, width=500)
|
| 630 |
content = gr.Textbox("", label="Konten", interactive=True)
|
| 631 |
-
view_outputs.click(fn=view_output, outputs=[title,
|
| 632 |
save_button= gr.Button("Save Change")
|
| 633 |
status = gr.HTML("")
|
| 634 |
save_button.click(fn=save, inputs =[title,content], outputs = status)
|
| 635 |
with gr.Tab("Formatted Output"):
|
| 636 |
view_change = gr.Button("View Change")
|
| 637 |
title = gr.HTML("")
|
| 638 |
-
img = gr.Image()
|
| 639 |
content = gr.HTML("")
|
| 640 |
-
view_outputs.click(fn=view_output, outputs=[title,
|
| 641 |
view_change.click(fn=view, outputs=[title,content])
|
| 642 |
with gr.Column():
|
| 643 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|
|
|
|
| 417 |
image_data= base64_string
|
| 418 |
os.remove(tmp_path)
|
| 419 |
|
| 420 |
+
# output_image_io = io.BytesIO()
|
| 421 |
+
# image.save(output_image_io, format='PNG')
|
| 422 |
+
# output_image_io.seek(0)
|
| 423 |
|
| 424 |
+
# # Upload gambar ke repo Hugging Face
|
| 425 |
+
# repo_name = get_full_repo_name(model_id="Article_Gen3", token="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")
|
| 426 |
+
# file_url = upload_file(
|
| 427 |
+
# path_or_fileobj=output_image_io.read(),
|
| 428 |
+
# path_in_repo="output_image.png",
|
| 429 |
+
# repo_id=repo_name,
|
| 430 |
+
# repo_type="space",
|
| 431 |
+
# token="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",
|
| 432 |
+
# )
|
| 433 |
|
| 434 |
except:
|
| 435 |
image = Image.open('botika_logo.jpeg')
|
|
|
|
| 505 |
if kontent:
|
| 506 |
status = "<h3>Berhasil Generate Artikel</h3>"
|
| 507 |
time.sleep(60)
|
| 508 |
+
return status,gambar
|
| 509 |
except:
|
| 510 |
status = "<h3>Gagal Generate Artikel</h3>"
|
| 511 |
+
gambar = Image.open('error.png')
|
| 512 |
return status
|
| 513 |
|
| 514 |
|
|
|
|
| 623 |
replicate_token = gr.Textbox(placeholder="Masukkan Token Replicate", type="password",label="Replicate Key")
|
| 624 |
button_scrap = gr.Button("Scrap Article")
|
| 625 |
status = gr.HTML("")
|
| 626 |
+
gambar = gr.Image(label="Generate Gambar")
|
| 627 |
+
button_scrap.click(fn=scrap, inputs=[link,backlink,keyword,versi,api_key,link_azure,replicate_token], outputs= status,gambar)
|
| 628 |
view_outputs = gr.Button("View Output")
|
| 629 |
with gr.Tab("Raw Output"):
|
| 630 |
title = gr.Textbox("", label="Judul", interactive=True)
|
|
|
|
| 631 |
content = gr.Textbox("", label="Konten", interactive=True)
|
| 632 |
+
view_outputs.click(fn=view_output, outputs=[title,content])
|
| 633 |
save_button= gr.Button("Save Change")
|
| 634 |
status = gr.HTML("")
|
| 635 |
save_button.click(fn=save, inputs =[title,content], outputs = status)
|
| 636 |
with gr.Tab("Formatted Output"):
|
| 637 |
view_change = gr.Button("View Change")
|
| 638 |
title = gr.HTML("")
|
|
|
|
| 639 |
content = gr.HTML("")
|
| 640 |
+
view_outputs.click(fn=view_output, outputs=[title,content])
|
| 641 |
view_change.click(fn=view, outputs=[title,content])
|
| 642 |
with gr.Column():
|
| 643 |
endpoint= gr.Textbox(placeholder="Masukkan Endpoint Wordpress", label="Endpoint Wordpress")
|