Tutorials  /  AI/ML

Generate AI Images with OpenJourney on centron A100 GPUs

Ccentron Redaktion · December 2025 ·10 min read ·AI/ML, Tutorial

OpenJourney is an image-generation model built on Stable Diffusion and released under the OpenRAIL license. It delivers results comparable to Midjourney and lets you produce realistic, high-quality artwork with the help of artificial intelligence. This guide shows you how to generate AI images with OpenJourney on a centron Cloud GPU instance. You will set up Jupyter Notebook and the required packages so you can run OpenJourney on a centron Cloud GPU server.

GPU

Need more GPU power for this project?

Dedicated NVIDIA GPUs (RTX A4000 to A100) from German data centers – from €92.59/month, billed by the hour, ready in minutes. Rent a GPU server →

Prerequisites

Before you start:

  • Provision an Ubuntu 22.04 A100 or RTX 6000 Ada Cloud GPU server at centron with at least:
    • 30 GB Memory
    • 350 GB NVMe Storage
  • Connect to the server via SSH and create a non-root user with sudo permissions.
  • Update the server.

Install Jupyter Notebook

Jupyter Notebook is an open-source, web-based development environment for building and sharing documents that include live code, visualizations, and equations. With Jupyter Notebook, you can use the performance of your centron Cloud GPU instance to execute resource-intensive models directly in your browser. Install Jupyter Notebook as follows.

Install the python3-pip package manager.

Console
$ sudo apt install python3-pip

Use pip to install the JupyterLab package.

Console
$ sudo pip install -U jupyterlab

To protect the JupyterLab interface, create a password hash with the command below.

Console
$ python3 -c "from jupyter_server.auth import passwd; print(passwd('STRONG_PASSWORD'))"

Copy the generated password hash.

Create a new JupyterLab configuration file.

Console
$ jupyter lab --generate-config

Edit the configuration file.

Console
$ nano ~/.jupyter/jupyter_lab_config.py

Locate the configuration entries below and set them like this.

Code
c.ServerApp.password = 'PASTE_PASSWORD_HASH'
c.ServerApp.allow_remote_access = True

Save and exit the file.

Open port 8888 in the firewall so the web interface is reachable.

Console
$ sudo ufw allow 8888

Create a folder to store images produced by OpenJourney.

Console
$ mkdir ~/Generated-Images

Launch the JupyterLab server in the background.

Console
$ jupyter lab --ip 0.0.0.0 &

Open the Jupyter web interface in your browser and log in using the password you configured.

Set Up the Environment

Next, prepare the image-generation environment. Install PyTorch, required Hugging Face libraries, and matplotlib so you can generate and display images in Jupyter Notebook.

In your browser, open the Jupyter web interface.

In the launcher, go to the Notebook area and select Python 3 (ipykernel) to create a new notebook.

To rename the notebook, right-click the filename and choose Rename.

In a code cell, run the commands below to install torch and torchvision.

Code
!pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118

After torch installs, add these commands to install the Hugging Face packages.

Code
!pip install transformers
!pip install diffusers
!pip install accelerate

These commands install the following tools:

  • Transformers: A collection of pre-trained models for tasks such as NLP, NER, translation, and sentiment analysis.
  • Diffusers: Pre-trained diffusion pipelines and components for building and training diffusion models.
  • Accelerate: Helps PyTorch scale across distributed setups and use accelerators like GPUs and TPUs for better speed and efficiency.

Install matplotlib.

Code
!pip install matplotlib

This installs matplotlib so you can show generated images in Jupyter Notebook.

Install ipywidgets.

Code
!pip install ipywidgets

Generate Images with OpenJourney

To create images with OpenJourney, import the needed modules, initialize the model, and enable GPU acceleration on CUDA.

Import the required modules.

Python
from diffusers import StableDiffusionPipeline
import torch
import matplotlib.pyplot as plt

The StableDiffusionPipeline class exposes the OpenJourney model for text-to-image generation. Torch provides tensor operations and GPU acceleration, and matplotlib lets you display the results.

Initialize the model.

Code
model_id = "prompthero/openjourney"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipe = pipe.to("cuda")

Using from_pretrained() loads the pipeline and prepares everything required to generate images from text.

The from_pretrained() parameters are:

  • model_id: Identifies the pipeline to load. Here it pulls "prompthero/openjourney". You can also point to a local weights folder or a checkpoint file path.
  • torch_dtype: Defines the tensor datatype for computations. float16 is selected so calculations run in 16-bit precision to reduce memory usage. You can allow automatic selection with torch_dtype = "auto". The default is torch_dtype = "full-precision".

Generate an image from a text prompt.

Code
prompt = "YOUR_PROMPT_HERE, mdjrny-v4 style"
images = pipe(prompt).images

This sends your prompt into the pipeline and stores the generated output. A new image is produced every time you run the cell. The mdjrny-v4 style suffix guides the model toward Midjourney-like aesthetics. You can improve results by adding more detail about lenses, environments, lighting, and similar attributes.

Display the generated image.

Code
plt.imshow(images[0])

If a generated image is flagged as Not Safe For Work (NSFW), the model can return an error and produce a blank output. Adjust your prompt or choose another seed to refine your results.

To hide axes on the image, run the following.

Code
plt.imshow(images[0])
plt.axis('off')
plt.show()

Save Generated Images

Set the directory you created earlier as the destination for saved images.

Code
save_directory = "‾/Generated-Images"

The target folder must already exist. Make sure you created it inside your home directory.

Save the images with a for loop.

Code
for i, image in enumerate(images):
    image.save(f"{save_directory}/image_{i}.png")

This stores every image in save_directory using filenames like image_{i}.png, where {i} is the list position.

In your terminal, confirm that the images are in the folder.

Console
$ ls ~/Generates-Images

To copy the generated images to your local machine, use a secure transfer method such as SFTP, FTP, or RSync.

Generate Multiple Images with OpenJourney

By default, the pipeline produces one image for each prompt. If you want several unique images from the same prompt, define how many outputs to create.

Adjust the prompt code to set the number of images.

Code
num_images = 5
prompt = ["YOUR_PROMPT_HERE, mdjrny-v4 style"] * num_images

This defines num_images and duplicates your prompt into a list of that size.

Generate multiple images.

Code
image_list = pipe(prompt).images

The image_list variable holds all created images for later use.

Render the generated images with an active-voice loop.

Code
for image in image_list:
    plt.imshow(image)
    plt.show()

The loop walks through image_list and displays each image with plt.imshow(image). You can also reuse the saving loop to export all images to your chosen directory.

Deterministic Output with OpenJourney

You can set a fixed random seed and pass it into the pipeline’s generator to get repeatable results. When you reuse the same seed with the generator, the model produces the same image output every time.

Create a new generator.

Code
prompt = "YOUR_PROMPT_HERE, mdjrny-v4 style"
generator = torch.Generator("cuda").manual_seed(2048)
images = pipe(prompt, guidance_scale=7.5, generator=generator).images

This code creates a generator and supplies it to the pipeline. The constant value in manual_seed() locks the randomness, which makes the model return the same result each time you run image generation. You may choose any integer for the manual seed. If you do not set a seed, the generator picks a new one on every run, which leads to different images.

Key Terms

The image-generation pipeline supports many parameters, but only pipe and prompt are required. The following explains optional settings you can use while generating images.

  • pipe: The text-to-image pipeline function. It receives the prompt and any extra configuration options.
  • prompt: The text input that steers the image creation. Replace "YOUR_PROMPT_HERE, mdjrny-v4 style" with your own prompt. If you remove the mdjrny-v4 style suffix, the model generates more generic images that are less aligned with a Midjourney-like look.
  • generator: A torch.Generator instance that controls random number creation. Providing a seed value such as 2048 makes outputs stable and deterministic when you reuse the same seed.
  • guidance_scale: Controls how strongly the pipeline follows your prompt and influences output quality. This classifier-free guidance emphasizes prompt alignment, which affects both quality and variety. Values around 7 to 8.5 generally work well, and the default is 7.5.
  • images: A list containing all generated image objects.
  • num_inference_steps: The number of inference steps used during generation. The default is 50, offering a tradeoff between speed and quality. Fewer steps produce faster results, while more steps can improve quality but take longer.

Conclusion

In this article, you created images with the OpenJourney model and used a centron A100 Cloud GPU server to speed up and improve image generation. You also built a Jupyter Notebook environment and installed the required libraries to generate, view, and save your images.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie AI/ML
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren