raannakasturi commited on
Commit
319999c
·
1 Parent(s): 8d39c59

Update image generation providers and change model to sdxl-turbo

Browse files
Files changed (1) hide show
  1. image.py +11 -8
image.py CHANGED
@@ -6,7 +6,7 @@ import requests
6
  from urllib.parse import quote
7
  from PIL import Image
8
  from g4f.client import Client
9
- from g4f.Provider import RetryProvider, PollinationsAI, Airforce, ReplicateHome, BlackboxCreateAgent
10
  from g4f.Provider.hf_space.BlackForestLabsFlux1Schnell import BlackForestLabsFlux1Schnell
11
  from g4f.Provider.hf_space.VoodoohopFlux1Schnell import VoodoohopFlux1Schnell
12
 
@@ -33,14 +33,15 @@ def generate_image(title, category, summary):
33
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
34
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
35
  client = Client()
 
36
  img_data = client.images.generate(
37
  provider=RetryProvider(
38
- providers=[ReplicateHome, Airforce],
39
  shuffle=True,
40
  single_provider_retry=True,
41
- max_retries=3,
42
  ),
43
- model="sdxl",
44
  prompt=prompt,
45
  negative_prompt=negative,
46
  response_format="b64_json",
@@ -56,12 +57,13 @@ def generate_image(title, category, summary):
56
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
57
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
58
  client = Client()
 
59
  img_data = client.images.generate(
60
  provider=RetryProvider(
61
- providers=[Airforce, PollinationsAI, BlackboxCreateAgent],
62
  shuffle=True,
63
  single_provider_retry=True,
64
- max_retries=3,
65
  ),
66
  model="flux",
67
  prompt=prompt,
@@ -79,12 +81,13 @@ def generate_image(title, category, summary):
79
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
80
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
81
  client = Client()
 
82
  img_data = client.images.generate(
83
  provider=RetryProvider(
84
- providers=[BlackForestLabsFlux1Schnell, VoodoohopFlux1Schnell],
85
  shuffle=True,
86
  single_provider_retry=True,
87
- max_retries=3,
88
  ),
89
  model="flux-schnell",
90
  prompt=prompt,
 
6
  from urllib.parse import quote
7
  from PIL import Image
8
  from g4f.client import Client
9
+ from g4f.Provider import RetryProvider, PollinationsAI, ImageLabs, Blackbox, HuggingSpace, Airforce
10
  from g4f.Provider.hf_space.BlackForestLabsFlux1Schnell import BlackForestLabsFlux1Schnell
11
  from g4f.Provider.hf_space.VoodoohopFlux1Schnell import VoodoohopFlux1Schnell
12
 
 
33
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
34
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
35
  client = Client()
36
+ time.sleep(20)
37
  img_data = client.images.generate(
38
  provider=RetryProvider(
39
+ providers=[ImageLabs, PollinationsAI],
40
  shuffle=True,
41
  single_provider_retry=True,
42
+ max_retries=5,
43
  ),
44
+ model="sdxl-turbo",
45
  prompt=prompt,
46
  negative_prompt=negative,
47
  response_format="b64_json",
 
57
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
58
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
59
  client = Client()
60
+ time.sleep(20)
61
  img_data = client.images.generate(
62
  provider=RetryProvider(
63
+ providers=[Airforce, PollinationsAI, Blackbox],
64
  shuffle=True,
65
  single_provider_retry=True,
66
+ max_retries=5,
67
  ),
68
  model="flux",
69
  prompt=prompt,
 
81
  negative="low quality, blurry, pixelated, bad anatomy, bad hands, three hands, three legs, bad arms, missing legs, missing arms, poorly drawn face, poorly rendered hands, bad face, fused face, cloned face, worst face, three crus, extra crus, fused crus, worst feet, three feet, fused feet, fused thigh, three thigh, extra thigh, worst thigh, missing fingers, extra fingers, ugly fingers, long fingers, bad composition, horn, extra eyes, huge eyes, 2girl, amputation, disconnected limbs, cartoon, cg, 3d, unreal, animate, cgi, render, artwork, illustration, 3d render, cinema 4d, artstation, octane render, mutated body parts, painting, oil painting, 2d, sketch, bad photography, bad photo, deviant art, aberrations, abstract, anime, black and white, collapsed, conjoined, creative, drawing, extra windows, harsh lighting, jpeg artifacts, low saturation, monochrome, multiple levels, overexposed, oversaturated, photoshop, rotten, surreal, twisted, UI, underexposed, unnatural, unreal engine, unrealistic, video game, deformed body features, NSFW, NUDE, vulgar, negative, unsuitable, inappropriate, offensive, revealing, sexual, explicit",
82
  prompt = f"Generate accurate image representing the {category} concept: ```{title.strip()}: {summary.strip()}```"
83
  client = Client()
84
+ time.sleep(20)
85
  img_data = client.images.generate(
86
  provider=RetryProvider(
87
+ providers=[BlackForestLabsFlux1Schnell, VoodoohopFlux1Schnell, HuggingSpace],
88
  shuffle=True,
89
  single_provider_retry=True,
90
+ max_retries=5,
91
  ),
92
  model="flux-schnell",
93
  prompt=prompt,