How to Run ERNIE-ViLG AI Art Generator in Google Colab Free

Channel: Machine Learning
Abstract: along with usage and comparisons with Stable Diffusion prompts. Run Hugging Faces Spaces Demo on your own Colab GPU or Locally – An easy to follow tut

ERNIE-ViLG is a new state-of-the-art text-to-image AI art generation model, that was recently released by Baidu.

It’s difficult to compare ERNIE-ViLG to Stable Diffusion because the model is Chinese. You can give it prompts in English, and it will first translate them to Chinese, and then start the image generation. So comparing it using the exact English prompt doesn’t seem like a fair comparison. You can check more examples on Github to get a better idea.

Given that it’s developed by Baidu, we can definitely assume it will improve in the near future, and since it’s open-source we’ll be seeing a lot of advanced implementations.

You can easily test it on Hugging Face https://huggingface.co/spaces/PaddlePaddle/ERNIE-ViLG.

In this tutorial we’ll take the demo from Hugging Face and run it on Google Colab, so we can generate images faster, without having to wait in queue.

Credit to 1littlecoder on YouTube for creating a tutorial on how to take HuggingFace demos very easily and use them in Colab.

Table of Contents
  1. Quick Demo of ERNIE-ViLG Running on Colab
  2. Example Results & Prompt Design
  3. Copy the ERNIE-ViLG HuggingFace Spaces Demo on Google Colab
  4. Additional Notes
    1. Where Can I See Image Generation Progress?
    2. It’s May Not Familiar with Some Popular Media
  5. Conclusion
  6. Resources & Acknowledgements
Quick Demo of ERNIE-ViLG Running on Colab https://bytexd.com/wp-content/uploads/2022/11/ERNIE-ViLG-Example-Usage.mp4 Example Results & Prompt Design

These are some of my results with ERNIE-ViLG. I think it’s great and I wish I knew Chinese to better use it.

 

a giant gundam japanese robot battlemech in city ruins, concept art, concept (1) a giant gundam japanese robot battlemech in city ruins, concept art, concept (1) supercar, night, city, red, luxury, speed, fast, driving, headlights, street, neon, sign, club 3 supercar, night, city, red, luxury, speed, fast, driving, headlights, street, neon, sign, club 3 ancient fortress, cyberpunk, futuristic, high-definition, 3d 5 ancient fortress, cyberpunk, futuristic, high-definition, 3d 5 ancient fortress, cyberpunk, futuristic, high-definition, 3d 4 ancient fortress, cyberpunk, futuristic, high-definition, 3d 4 cute potato, kawaii cute potato, kawaii

You can find some info regarding prompts in their docs page, where it also has a section on prompts. It should give you a few clues on how to better write prompts for ERNIE-VilG.

It also links to prompt tips for DALL-E 2, prompt tips for Disco Diffusion, and Aesthetics Wiki. This suggests that perhaps it works in a similar way.

The example prompts do seem a bit similar to the ones used for Disco Diffusion.

Copy the ERNIE-ViLG HuggingFace Spaces Demo on Google Colab

To copy the Hugging Face space on our Colab, follow these steps:

  1. Open a new Google Colab. You can just go here https://colab.research.google.com/ and a popup should appear with some options on what you files you want to open. Just click New notebook at the bottom. Open a New Notebook in Google ColabOpen a New Notebook in Google Colab
  2. Paste the following code in any cell and run it. This will download the Hugging Face space onto your Colab, and then it will install ERNIE-ViLG’s dependencies. It should be just a few minutes.
    !git clone https://huggingface.co/spaces/PaddlePaddle/ERNIE-ViLG
    %cd ERNIE-ViLG
    !pip install -r requirements.txt -q
    !pip install gradio -q
  3. Next we want to edit the app.py file.
    1. Open the file browser on the left of Google Colab, expand the ERNIE-ViLG directory, and double click app.py. This will open the file on your right.
    2. Scroll to the bottom and change block.queue(concurrency_count=128).launch() to block.queue(concurrency_count=128).launch(share=True).
    3. Then press Ctrl+S to save the file.
    Editing the app.py FileEditing the app.py File
  4. Finally just run !python app.py in another cell and wait ~1 minute.
  5. After it’s done you’ll see some URLs generated. Click on the public URL. It should end with .gradio.app. Access ERNIE-ViLG Gradio User InterfaceAccess ERNIE-ViLG Gradio User Interface
  6. That’s it! Now you can start using ERNIE-ViLG in your browser. ERNIE-ViLG Web InterfaceERNIE-ViLG Web Interface
Additional Notes Where Can I See Image Generation Progress?

While generating you can check back in the Google Colab, and you’ll be able to see the image generation progress in the output for the last cell you ran.

View ERNIE-ViLG ProgressView ERNIE-ViLG Progress It’s May Not Familiar with Some Popular Media

Given the popularity of The Witcher franchise, you’d expect more accurate results. Perhaps we’ll find out later on what it was trained on so that it missed Geralt of Rivia.

Trying to generate Geralt of Rivia with ERNIE-ViLGTrying to generate Geralt of Rivia with ERNIE-ViLG Conclusion

In this tutorial we set up the ERNIE-ViLG Hugging Face Space on our Google Colab to create AI generated images free and faster.

We’re looking forward to seeing how this model will evolve. Since it’s developed by Baidu we can probably expect some amazing developments in the near future.

If you have any questions or have encountered any issues please feel free to leave a comment.

Resources & Acknowledgements
  • NEW Text to Image AI Generator Hits the Scene – ERNIE-ViLG AI – Excellent video by MattVidPro AI presenting an overview of ERNIE-ViLG, along with usage and comparisons with Stable Diffusion prompts.
  • Run Hugging Faces Spaces Demo on your own Colab GPU or Locally – An easy to follow tutorial by 1littlecoder on how to run Hugging Face Spaces demos on Google Colab or locally so you can reduce waiting times.
  • The ERNIE-ViLG Readme on Github – You have to translate this if you don’t understand Chinese. Here you’ll find how to install the Python library and how to use it, as well as more generated image examples, and a prompt guide.

Ref From: bytexd

Related articles