mirror of
https://github.com/ollama/ollama-python.git
synced 2026-05-01 11:48:17 +08:00
simplify examples
This commit is contained in:
parent
1503233085
commit
9611be43d6
@ -1,18 +0,0 @@
|
||||
# Image generation is experimental and currently only available on macOS
|
||||
|
||||
import base64
|
||||
|
||||
from ollama import generate
|
||||
|
||||
prompt = 'a sunset over mountains'
|
||||
print(f'Prompt: {prompt}')
|
||||
|
||||
for response in generate(model='x/z-image-turbo', prompt=prompt, stream=True):
|
||||
if response.image:
|
||||
# Final response contains the image
|
||||
with open('output.png', 'wb') as f:
|
||||
f.write(base64.b64decode(response.image))
|
||||
print('\nImage saved to output.png')
|
||||
else:
|
||||
# Progress update
|
||||
print(f'Progress: {response.completed}/{response.total}', end='\r')
|
||||
@ -7,15 +7,12 @@ from ollama import generate
|
||||
prompt = 'a sunset over mountains'
|
||||
print(f'Prompt: {prompt}')
|
||||
|
||||
response = generate(
|
||||
model='x/z-image-turbo',
|
||||
prompt=prompt,
|
||||
width=1024,
|
||||
height=768,
|
||||
)
|
||||
|
||||
# Save the generated image
|
||||
with open('output.png', 'wb') as f:
|
||||
f.write(base64.b64decode(response.image))
|
||||
|
||||
print('Image saved to output.png')
|
||||
for response in generate(model='x/z-image-turbo', prompt=prompt, stream=True):
|
||||
if response.image:
|
||||
# Final response contains the image
|
||||
with open('output.png', 'wb') as f:
|
||||
f.write(base64.b64decode(response.image))
|
||||
print('\nImage saved to output.png')
|
||||
else:
|
||||
# Progress update
|
||||
print(f'Progress: {response.completed}/{response.total}', end='\r')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user