File size: 1,478 Bytes
5760606
788a6f6
391b2d9
1bc7525
bbf59eb
 
788a6f6
5760606
0eb1950
 
a46217d
 
 
 
 
 
 
1bc7525
 
0eb1950
739e67a
a46217d
739e67a
 
1bc7525
0eb1950
bbf59eb
788a6f6
bbf59eb
739e67a
1bc7525
 
391b2d9
788a6f6
 
391b2d9
 
 
788a6f6
 
 
391b2d9
 
 
739e67a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from ai import image
from ai_tasks.headlines_for_ai_images import generate_headline_and_prompt
from ai_tasks.headlines_for_images import get_headline_for_image
from ai_tasks.text_summary import summarize_text
from code_tasks.images_in_url import get_images_from_url
from code_tasks.text_in_url import get_text_from_url
from custom_code.image_analysis import analyze_images
from utils.io import print_assistant, print_system, user_input


"""
"300x50",
"300x250",
"300x600",
"728x90",
"160x600",
"""


def run():
    url = user_input("URL: ")
    dimensions = user_input("Dimensions: ")

    # Code tasks (most code was generated by ChatGPT-4)
    print_system("Getting URL data...")
    text = get_text_from_url(url)
    images = get_images_from_url(url)
    image_infos = analyze_images(images)

    # AI tasks
    summary = summarize_text(text)
    print_assistant(summary)
    # Pick an image and generate a headline
    headline = get_headline_for_image(summary, dimensions, image_infos)
    print_assistant(headline)
    # Generate a headline and an image
    headline_prompt = generate_headline_and_prompt(summary, dimensions)
    print_system("Generating AI images...")
    ai_image = image.urls(
        headline_prompt["prompt"], size=headline_prompt["dimension_to_map"]
    )[0]
    print_system(f"Prompt: {headline_prompt['prompt']}")
    print_assistant(headline_prompt["ad_dimension"])
    print_assistant(headline_prompt["headline"])
    print_assistant(ai_image)