1

OpenJourney

 1 year ago
source link: https://open-journey.github.io/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

OpenJourney: Midjourney, but open source...!

OpenJourney is a Text-to-Image AI model which has the goal of bringing an open source equivalent to Midjourney to the people. It is currently based on prompthero/midjourney-v4-diffusion and is under further developments by Muhammadreza Haghiri to get closer results to Midjourney AI.

OpenJourney is trying to make AI art more accessible and affordable for people who enjoy making their ideas to great pieces of art and we try to make you, the creator of the art, the actual owner of the generated art.

Why OpenJourney?

First of all, as long as you have a computer (specially a computer with a GPU which has CUDA support) you are able to generate awesome art on your own. Second, for selling your generated art, you have to pay the platform you have used to create the art.

The main thought behind OpenJourney is that you must have all the control on the tool and also generated material. You must be able to run it wherever you want, you must be able to generate whatever you want and also you must be able to sell your generated art in any form you like!

Sample Generated Art

asset-1.png

Who can use OpenJourney

Short answer : everyone!

Long answer on the other hand is everyone who has artistic tendencies or ideas, but cant implement them as they wish. Let's make it a little bit more clear. For example, you had a dream about a calm sea, and saw an ancient battleship seeking the shore. You can make it to an artistic painting and keep it in your digital assets.

Also, you can make a carrier! How you may ask? it is easy. In our time, we have a lot of digital asset marketplaces such as NFT marketplaces that you can sell your items and make a carrier. Never underestimate the power open source software provides.

Applications

There is a vast majority of applications for an AI content generator and you can use it in any way you want. For example, you just enjoy seeing your ideas becoming artistic pieces of work, so this is an application for you.

Or even if you work in a certain field and you need an artificial assistant, you can count on OpenJourney. This is an example of OpenJourney for interior design:

asset-2.png

See? This is how easy you can turn your ideas to a piece of art that can be used as an sketch, or even better, the proposal for your customers.

How to use OpenJourney

For using OpenJourney you have to make an account in huggingface and make a token with write permission.

Now, it's time to do some installations (mind that for this particular guide, you have to have at least one NVIDIA GPU with CUDA support. In order to install the needed libraries, you only need to run the following cell:

pip install diffusers transformers ftfy scipy accelerate

Remember that accelerate tunes your VRAM usage and makes the whole process of image generation much faster.

After you installed all the libraries, you have to use huggingface-cli login command in your terminal and give your token to it. Then, it'll log you in into your huggingface account.

Importing needed libraries

Now, you have to import the needed libraries in order to get the whole thing to work. These are what you need:

import torch
from torch import autocast
from diffusers.models import AutoencoderKL
from diffusers import StableDiffusionPipeline
			

You also can add other libraries for image processing and manipulation, such as PIL or cv2, and you also can have add other libraries you need. All libraries above are just for image generation.

Creating the pipeline

Creating a pipeline is quite easy, you just have to write this piece of code here:

pipe = StableDiffusionPipeline.from_pretrained("openjourney/openjourney", use_auth_token=True)
pipe = pipe.to("cuda")
			

Now, we can start image generation. But since OpenJourney is based on the main Stable Diffusion pipelines, it has a strict NSFW filtering function, and in order to disable that, you may consider using these lines of code.

def dummy(images, **kwargs): 
	return images, False
			
pipe.safety_checker = dummy
			

Important Note: Since AI art generator software is used by pretty much all the people in any age, consider NOT disabling this filter when you give its access to minors. We do not want bad content to be shown to minors or sensitive people.

Generating and Saving Images

First, you have to create your prompt like this:

prompt = "painting of a building in a stunning landscape"
prompt = f"mdjrny-v4 style {prompt}"
			

That mdjrny-v4 style part is currently needed for image generation in the right style, but it may be not necessary in further updates.

Then, you have to run this:

with autocast("cuda"):
  image = pipe(prompt=prompt, num_inference_steps=100, width=512, height=512, guidance_scale=15).images[0]
			

And finally, with image.save("image.png") you'll be able to save your image and enjoy.

Links

Stable Diffusion: The basic model OpenJourney is built on top of.

OpenJourney on huggingface: For more information and instructions.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK