Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import PIL | |
| from PIL import Image | |
| from PIL import ImageDraw | |
| from PIL import ImageFont | |
| import ast | |
| def predict(image, text,x_cor, y_cor, font_size, font_color, align, line_spacing): | |
| # img = Image.open('/content/bean_youtube_exam.JPG') | |
| img = Image.fromarray(image) | |
| I1 = ImageDraw.Draw(img) | |
| f_size = int(font_size) | |
| myFont = ImageFont.truetype('Quintessential-Regular.ttf', f_size) | |
| if font_color[0] == "(": | |
| font_color = ast.literal_eval(font_color) | |
| I1.multiline_text((int(x_cor), int(y_cor)), text, font=myFont, fill = font_color, spacing = line_spacing, align = align) | |
| return img | |
| intr = gr.Interface(predict, ["image", gr.Textbox(value="Is AI the Future of Fraud? \nFind out how ChatGPT Could Help You MAKE Fraud!", lines=10), | |
| gr.Number(value=10), gr.Number(value=10), gr.Number(value=50), | |
| gr.Textbox(value="white"), gr.Textbox(value="left"), gr.Number(value=50)], | |
| "image", title = "Apply text on images",debug=True, description = "Max 10 lines, specific color rgb format" | |
| ,examples=[["bean_youtube_exam.JPG", "Is AI the Future of Fraud? \nFind out how ChatGPT Could Help You MAKE Fraud!",10, 10, 30, "white", "left", 20], | |
| ["distantlights1fb.jpg","Is AI the Future of Fraud? \nFind out how ChatGPT Could Help You MAKE Fraud!",20, 30, 40, "(255,200,100)", "right", 40 ]]) | |
| intr.launch(inline = False) |