Spaces:
Runtime error
Runtime error
Commit ·
6d65302
1
Parent(s): 22bb995
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,7 @@ import random
|
|
| 5 |
from PIL import Image, ImageFont, ImageDraw
|
| 6 |
import gradio as gr
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
def igc(content_title='content_title',
|
| 11 |
-
account_name ='@' + 'a n a l y s e r__s t u d i o',
|
| 12 |
sub_title='Add sample text Here',
|
| 13 |
sub_title_explanation='This text is an example that helps you explain the subtopic in more detail. You have the chance to provide additional information and give a clear explanation of the subtopic. Use this opportunity to share your knowledge and insights, and help the reader understand the subtopic better.',
|
| 14 |
sub_title2='Add sample text Here',
|
|
@@ -67,8 +64,6 @@ def igc(content_title='content_title',
|
|
| 67 |
sub_title_list = [sub_title, sub_title2, sub_title3, sub_title4, sub_title5]
|
| 68 |
sub_title_explanation_list = [sub_title_explanation, sub_title_explanation2, sub_title_explanation3, sub_title_explanation4, sub_title_explanation5]
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
sub_title_font = ImageFont.truetype('Font/Poppins-Bold.ttf', 80)
|
| 73 |
sub_title_number_font = ImageFont.truetype('Font/Poppins-Bold.ttf', 120)
|
| 74 |
sub_title_explanation_font = ImageFont.truetype('Font/Poppins-Medium.ttf', 55)
|
|
@@ -79,18 +74,23 @@ def igc(content_title='content_title',
|
|
| 79 |
sub_background_image_draw = ImageDraw.Draw(sub_background_image)
|
| 80 |
if len(sub_title_list[i]) < 22:
|
| 81 |
sub_title_list[i] = textwrap.fill(sub_title_list[i], width=12, break_long_words=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
else:
|
| 83 |
sub_title_list[i] = textwrap.fill(sub_title_list[i], width=22, break_long_words=False)
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
make_archive('Result', 'zip', 'Result')
|
| 90 |
return 'Result.zip'
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
input_title = gr.inputs.Textbox(label="Title")
|
| 95 |
input_sub_title = gr.inputs.Textbox(label="Subtitle")
|
| 96 |
input_sub_title_explanation = gr.inputs.Textbox(label="Subtitle Explanation")
|
|
@@ -107,4 +107,4 @@ demo = gr.Interface(
|
|
| 107 |
fn=igc,
|
| 108 |
inputs=[input_title,input_sub_title,input_sub_title_explanation,input_sub_title2,input_sub_title_explanation2,input_sub_title3,input_sub_title_explanation3,input_sub_title4,input_sub_title_explanation4,input_sub_title5,input_sub_title_explanation5],outputs="file",output_filepath="Result.zip")
|
| 109 |
|
| 110 |
-
demo.launch(
|
|
|
|
| 5 |
from PIL import Image, ImageFont, ImageDraw
|
| 6 |
import gradio as gr
|
| 7 |
|
|
|
|
|
|
|
| 8 |
def igc(content_title='content_title',
|
|
|
|
| 9 |
sub_title='Add sample text Here',
|
| 10 |
sub_title_explanation='This text is an example that helps you explain the subtopic in more detail. You have the chance to provide additional information and give a clear explanation of the subtopic. Use this opportunity to share your knowledge and insights, and help the reader understand the subtopic better.',
|
| 11 |
sub_title2='Add sample text Here',
|
|
|
|
| 64 |
sub_title_list = [sub_title, sub_title2, sub_title3, sub_title4, sub_title5]
|
| 65 |
sub_title_explanation_list = [sub_title_explanation, sub_title_explanation2, sub_title_explanation3, sub_title_explanation4, sub_title_explanation5]
|
| 66 |
|
|
|
|
|
|
|
| 67 |
sub_title_font = ImageFont.truetype('Font/Poppins-Bold.ttf', 80)
|
| 68 |
sub_title_number_font = ImageFont.truetype('Font/Poppins-Bold.ttf', 120)
|
| 69 |
sub_title_explanation_font = ImageFont.truetype('Font/Poppins-Medium.ttf', 55)
|
|
|
|
| 74 |
sub_background_image_draw = ImageDraw.Draw(sub_background_image)
|
| 75 |
if len(sub_title_list[i]) < 22:
|
| 76 |
sub_title_list[i] = textwrap.fill(sub_title_list[i], width=12, break_long_words=False)
|
| 77 |
+
sub_title_explanation_list[i] = textwrap.fill(sub_title_explanation_list[i], width=35,
|
| 78 |
+
break_long_words=False)
|
| 79 |
+
sub_background_image_draw.text((450, 520), sub_title_list[i].title(), font=sub_title_font, fill=(0, 0, 0))
|
| 80 |
+
sub_background_image_draw.text((517, 850), sub_title_explanation_list[i].title(),
|
| 81 |
+
font=sub_title_explanation_font, fill=(0, 0, 0))
|
| 82 |
+
sub_background_image_draw.text((290, 540), str(i + 1), font=sub_title_number_font, fill=(255, 255, 255))
|
| 83 |
+
sub_background_image.save('Result/' + "Sub_Page" + str(i + 1) + ".png")
|
| 84 |
else:
|
| 85 |
sub_title_list[i] = textwrap.fill(sub_title_list[i], width=22, break_long_words=False)
|
| 86 |
+
sub_title_explanation_list[i] = textwrap.fill(sub_title_explanation_list[i], width=35, break_long_words=False)
|
| 87 |
+
sub_background_image_draw.text((450, 520), sub_title_list[i].title(), font= sub_title_font, fill=(0, 0, 0) )
|
| 88 |
+
sub_background_image_draw.text((517, 850), sub_title_explanation_list[i].title(), font=sub_title_explanation_font, fill=(0, 0, 0))
|
| 89 |
+
sub_background_image_draw.text((290, 540), str(i + 1), font=sub_title_number_font,fill=(255, 255, 255))
|
| 90 |
+
sub_background_image.save('Result/' + "Sub_Page" + str(i + 1) + ".png")
|
| 91 |
make_archive('Result', 'zip', 'Result')
|
| 92 |
return 'Result.zip'
|
| 93 |
|
|
|
|
|
|
|
| 94 |
input_title = gr.inputs.Textbox(label="Title")
|
| 95 |
input_sub_title = gr.inputs.Textbox(label="Subtitle")
|
| 96 |
input_sub_title_explanation = gr.inputs.Textbox(label="Subtitle Explanation")
|
|
|
|
| 107 |
fn=igc,
|
| 108 |
inputs=[input_title,input_sub_title,input_sub_title_explanation,input_sub_title2,input_sub_title_explanation2,input_sub_title3,input_sub_title_explanation3,input_sub_title4,input_sub_title_explanation4,input_sub_title5,input_sub_title_explanation5],outputs="file",output_filepath="Result.zip")
|
| 109 |
|
| 110 |
+
demo.launch(share=True)
|