1
1
<div align =" center " >
2
- <b >>PyPi IS NOT UPDATE! PLEASE INSTALL FROM THE REPO!</b >
3
- <br >
4
-
5
2
<img src =" https://github.com/ItsCEED/ImaginePy-Midjourney-Free-Alternative/blob/main/docs/imagine_logo.gif " width =" 10% " >
6
3
7
4
** ImaginePy**
@@ -72,22 +69,29 @@ The following is a minimal example of using ImaginePy in a script. It gets the g
72
69
from the text and increases the quality.
73
70
74
71
``` python
75
- from imaginepy import Imagine, Style, Ratio
72
+ from imaginepy import Imagine
73
+ from imaginepy.constants import *
74
+
76
75
77
76
def main ():
78
- imagine = Imagine(style = Style. ANIME_V2 )
77
+ imagine = Imagine()
79
78
80
79
img_data = imagine.sdprem(
81
80
prompt = " Woman sitting on a table, looking at the sky, seen from behind" ,
82
- style = Style.ANIME_V2 ,
83
- ratio = Ratio.RATIO_16X9
81
+ style = Style.NO_STYLE ,
82
+ ratio = Ratio.RATIO_16X9 ,
83
+ negative = " " ,
84
+ seed = 1000 ,
85
+ cfg = 16 ,
86
+ model = Model.REALISTIC ,
87
+ asbase64 = False # default is false, putting it here as presentation.
84
88
)
85
89
86
90
if img_data is None :
87
91
print (" An error occurred while generating the image." )
88
92
return
89
93
90
- img_data = imagine.upscale(image = img_data)
94
+ img_data = imagine.upscale(img_data)
91
95
92
96
if img_data is None :
93
97
print (" An error occurred while upscaling the image." )
@@ -99,6 +103,7 @@ def main():
99
103
except Exception as e:
100
104
print (f " An error occurred while writing the image to file: { e} " )
101
105
106
+
102
107
if __name__ == " __main__" :
103
108
main()
104
109
```
@@ -107,16 +112,21 @@ Async version
107
112
108
113
``` python
109
114
import asyncio
110
- from imaginepy import AsyncImagine, Style, Ratio
115
+ from imaginepy import AsyncImagine
116
+ from imaginepy.constants import *
111
117
112
118
113
119
async def main ():
114
- imagine = AsyncImagine(style = Style.ANIME_V2 )
115
-
116
- img_data = await imagine.sdprem(
120
+ imagine = AsyncImagine()
121
+ img_data = imagine.sdprem(
117
122
prompt = " Woman sitting on a table, looking at the sky, seen from behind" ,
118
- style = Style.ANIME_V2 ,
119
- ratio = Ratio.RATIO_16X9
123
+ style = Style.NO_STYLE ,
124
+ ratio = Ratio.RATIO_16X9 ,
125
+ negative = " " ,
126
+ seed = 1000 ,
127
+ cfg = 16 ,
128
+ model = Model.REALISTIC ,
129
+ asbase64 = False # default is false, putting it here as presentation.
120
130
)
121
131
122
132
if img_data is None :
@@ -129,16 +139,18 @@ async def main():
129
139
print (" An error occurred while upscaling the image." )
130
140
return
131
141
132
- await imagine.close()
133
142
try :
134
143
with open (" example.png" , mode = " wb" ) as img_file:
135
144
img_file.write(img_data)
136
145
except Exception as e:
137
146
print (f " An error occurred while writing the image to file: { e} " )
138
147
148
+ await imagine.close()
149
+
139
150
140
151
if __name__ == " __main__" :
141
152
asyncio.run(main())
153
+
142
154
```
143
155
144
156
## Credit
0 commit comments