Skip to content
ga2631Public

About

A PoC AI-powered baby face prediction and emotion variations generator using FastAPI, Midjourney (Niji 5), and Pillow image processing.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Appplication name Demo Momy backend
Author Tan Huynh Nhat
Created date 08/01/2024
Version 0.0.1 (Alpha)

Source code demo Momy AI generate baby face

forthebadge made-with-python Open In Collab

A simple code to generate baby face use some AI tool. This repo only use to demo, so the source code is not clear and not safety

My research document in here1

Requirement

Language/Package Version Description
python 3.11.6 Programing language
fastapi 0.108.0 a modern, fast (high-performance), web framework for building APIs
uvicorn 0.25.0 Uvicorn is an ASGI web server implementation for Python
requests 2.31.0 HTTP library
pydantic 2.5.3 Data validation library
pydash 7.0.6 Lo-Dash for python
midjourney_api_client 1.0.1 Useapi.net provides a simple, reliable and affordable way to use Midjourney via standard REST API

How to use

Prepare enviroment

First, you need create virtualenv project's codebases. To do this, you must install virtualenv. Execute below command

pip install virtualenv

After install virtualenv, you need go to app dir and create virtualenv.

cd app
virtualenv enviroments

Now, you can install requirement package above. Or easier, you just execute below command

pip install -r requirements.txt

Start server

At app dir, execute below command to start server

uvicorn main:app --host 0.0.0.0 --port 8000

with: --host Bind socket to this host. Default: 127.0.0.1 --port Bind socket to this port. If 0, an available port will be picked. Default: 8000

After start server, you can access the APIs of project.

If you need API documentation, you can go to this url http://0.0.0.0:8000/docs. And... boooom💥! All API are here

Client

Just easy, open file src/index.html. Done!!!

How to AI generate work

To generate baby image, you need an image of parents, similar rate and sex of your AI baby. You can do that in client.

In client page, you can see 5 option mom_percent and dad_percent generate:

  1. Dad 0% - 100% Mom
  2. Dad 25% - 75% Mom
  3. Dad 50% - 50% Mom
  4. Dad 75% - 25% Mom
  5. Dad 100% - 0% Mom

And, you can also see 2 option of sex:

  • Male: is baby boy
  • Female: is baby girl

When you upload image of parents, I save these images to server and upload to Discord. After upload to Discord, I will receive mom_url and dad_url.

Then, from your option selected, I generate a prompt for Midjourney AI. Prompt structure is below

{mom_url} {dad_url} simple sticker cartoon neonate {sex} face, neonate {sex} face is smiling, image 1 similar rate is {mom_percent}% and image 2 similar rate is {dad_percent}% in white background, simple graphic design, symmetrical, 300 dpi, –-no glasses, –-no mockup --v 4 --s 750

After that, I use API of useapi.net to generate AI baby image.

Pricing

No such thing as a free lunch

-- Pierre Dos Utt

In this project, I use Midjourney basic plan and useapi.net subscribe. Total price is $20/month

Base on Midjourney time generate to calculate cost of per user. Corporeality:

  • Averange time of generate is 45 seconds = $0.038
  • Fixed costs of useapi.net is $0.038
  • Total cost of 1 user is $0.076 ~ 1,866.75 VND

Discord

I can't find any plan of Discord pricing. But, I has been find discription of Discord2

All bots can make up to 50 requests per second to our API. If no authorization header is provided, then the limit is applied to the IP address. This is independent of any individual rate limit on a route. If your bot gets big enough, based on its functionality, it may be impossible to stay below 50 requests per second during normal operations.

Global rate limit issues generally show up as repeatedly getting banned from the Discord API when your bot starts (see below). If your bot gets temporarily Cloudflare banned from the Discord API every once in a while, it is most likely not a global rate limit issue. You probably had a spike of errors that was not properly handled and hit our error threshold.

Midjourney

Midjourney has 4 pricing plans3

Plan Price Corresponding quantity (1 user = 45s)
Basic $10/3.3 hr(s)/month 264 users/month
Standard $15/15 hr(s)/month 1200 users/month
Pro $60/30 hr(s)/month 2400 users/month
Mega $120/60 hr(s)/month 4800 users/month

Useapi.net

$10/monthly subscription.4

Footnotes

  1. Momy document research ↩

  2. Discord Rate Limits ↩

  3. Midjourney pricing plan ↩

  4. Useapi.net pricing plan ↩

About

A PoC AI-powered baby face prediction and emotion variations generator using FastAPI, Midjourney (Niji 5), and Pillow image processing.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages