Dede16 commited on
Commit
ae69e39
·
1 Parent(s): c33754e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -415,6 +415,21 @@ def artikel_processing(link_scrap,backlink,keyword,models,api_key,azure_api_base
415
  base64_string = base64.b64decode(base64_string)
416
  image_data= base64_string
417
  os.remove(tmp_path)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  except:
419
  image = Image.open('botika_logo.jpeg')
420
  image = image.crop((3,0,1645,1024))
@@ -539,9 +554,9 @@ def view_outputs():
539
  title = '<h1>'+judul+'</h1>'
540
  with open('kontent.txt', 'r') as file:
541
  kontent = file.read()
542
- with open('image_data.txt', 'rb') as file:
543
- file_content = file.read()
544
- return title,file_content,kontent
545
 
546
 
547
  with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator:
 
415
  base64_string = base64.b64decode(base64_string)
416
  image_data= base64_string
417
  os.remove(tmp_path)
418
+
419
+ output_image_io = io.BytesIO()
420
+ image.save(output_image_io, format='PNG')
421
+ output_image_io.seek(0)
422
+
423
+ # Upload gambar ke repo Hugging Face
424
+ repo_name = get_full_repo_name(model_id="Article_Gen3", token="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")
425
+ file_url = upload_file(
426
+ path_or_fileobj=output_image_io.read(),
427
+ path_in_repo="output_image.png",
428
+ repo_id=repo_name,
429
+ repo_type="space",
430
+ token="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",
431
+ )
432
+
433
  except:
434
  image = Image.open('botika_logo.jpeg')
435
  image = image.crop((3,0,1645,1024))
 
554
  title = '<h1>'+judul+'</h1>'
555
  with open('kontent.txt', 'r') as file:
556
  kontent = file.read()
557
+ image = Image.open('output_image.png')
558
+
559
+ return title,image,kontent
560
 
561
 
562
  with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_generator: