The Ultimate Guide to Generating Images for Dating Profiles with Stable Diffusion on Astria.ai

The Ultimate Guide to Generating Images for Dating Profiles with Stable Diffusion on Astria.ai

Introduction

As a developer, when you are building user-facing apps, especially in the domain of online dating, you should ideally provide tools that allow the user to improve their dating profile images, so that they can stand out from the clutter and create a fabulous first impression.

Great profile images benefit both the user and the app. The user seeking a date can secure potential matches and ensure that they are ‘swiped right’. The app, on the other hand, benefits from great images and better matchmaking possibilities, while keeping users hooked.

In the past, you would have done this by integrating filters or providing simple image correction and editing tweaks to your users, who could use these tools to improve their existing images.

However, with Stable Diffusion-powered image generation technology, we can now go a step further — which is, to allow dating app users to display themselves in various moods, against multiple backgrounds, engaged in activities that their potential matches might find attractive. It is no longer required that they have existing photographs of reading a book, sitting in a downtown cafe, or going for a trek. They can have generic photographs of themselves, which they can now use — courtesy of your integration with Astria.ai — to generate stunning new ones in settings of their choice.

In this article, we will show you how to leverage fine-tuned Stable Diffusion models on Astria.ai, to create simple yet advanced image generation APIs that you can employ to help your app users create eye-catching profile photographs that attract engagement.

Astria.ai is quite powerful for this purpose, as it allows a higher control on image generation than any other platform out there. Also, the API is easy to integrate, making it simple for you to build advanced image generation features on their app without delving into Stable Diffusion deployment, or MLOps, or the specifics of infrastructure.

Astria.ai Key Features

Here’s what Astria.ai can do.

AI Photoshoot

The platform offers an innovative AI Photoshoot experience, where its advanced algorithms capture and enhance photos to perfection, ensuring the final images look smooth and alluring.

Fine-Tuning Model

The Fine-Tuning Model allows for precise adjustments to lighting, color balance, and other factors, resulting in professional-quality images that exude confidence and charm.

SDXL Training

With the SDXL training technology, the model learns from user preferences and feedback, while continuously improving its performance to meet the evolving needs of consumers.

ControlNet

Take control of the photo editing process with ControlNet, a feature that enables you to customize and fine-tune every aspect of your images with ease.

Inpainting and Masking

Astria.ai’s advanced Inpainting and Masking capabilities seamlessly remove unwanted elements from photos while preserving the integrity of the original images.

Additionally, Astria.ai offers the following features to further enhance profile photos:

Face Inpainting: Smooths out imperfections and enhances facial features to preserve identity and similarity to the original person. It also prevents distortion in faces commonly generated by Stable Diffusion.

Face Swap: Improves identity and similarity to the original images by swapping the facial features of the generated images with the original ones.

FaceId: A low-cost and time-effective feature for face generation that avoids fine-tuning.

LoRAs: Helps generate realistic-looking images with the help of advanced LoRAs technology.

Prompt Masking: Safeguards privacy by easily masking sensitive information or backgrounds in photos.

Generating Images

Astria.ai offers a powerful feature that allows developers to generate high-quality images from text, which can revolutionize the way you can offer content creation tools on dating apps. Here’s how it works:

Choose a Model: It provides public and private text-to-image generation models. Select the model that best suits your needs and preferences.

Input Your Prompt: Enter your text prompt on Astria.ai’s UI. This could be a description of the image you want to create, a concept you’d like to explore, or any other text-based input.

Negative Prompt: It also allows you to use negative prompts to specify what you don’t want to see in the generated images. Simply include keywords or phrases that you want to avoid, and it will adjust the image generation process accordingly.

With Astria.ai’s text-to-image generation feature, you can help your app users create captivating visuals for their dating profiles that reflect the user’s personality and interests. Whether the user is looking to showcase their favorite hobbies, express their sense of humor, or convey their unique taste in music, everything is now possible at the click of a button.

Preparing to Use Astria.ai’s API for Generating Innovative Dating Profile Images: A Step-by-Step Guide

Ready to integrate Astria’s advanced technology into your platform to enable users to generate novel dating profile images?

Here’s a step-by-step guide to help you prepare for the process.

We will showcase the entire flow through both the UI and the Astria.ai APIs, so that, as a developer, you can understand exactly what’s happening under the hood when you are sending your API requests.

Let’s dive in:

Sign In

If you’re already an Astria.ai user, simply sign in to your account to get started. If you’re new to Astria.ai, click on New User and follow the prompts to create an account.

Create Your Tunes

Tunes are the models created using your images. This personalized model ensures that your photos are enhanced to match your unique style and preferences.

As you can see on the top right, there’s a New fine-tuning option. You can use this to create your model and generate images based on your prompts.

When you click on ‘New Fine-tune’, the screen below will open up.

Now, follow the steps below to fine-tune your model using input images:

Title: Enter the person’s name, e.g. Rayyan. Or, choose whatever title that fits your needs. Choosing a title is not a part of the actual training of the model.

Class Name: Enter ‘man’ or ‘woman’, or possibly boy, girl, cat, or dog. This is very important as it is a part of the actual technical training of your model. We automatically generate images of the ‘class’ while training, and by comparing them to your images (the training set), the model ‘learns’ your subject’s unique features.

Base Tune: Select a baseline model on which you would like to train. For realistic generations, we recommend using Realistic Vision v5.1, while for more artistic training, use Deliberate.

Images: The following are tips for training images.

  1. Upload both portrait and full-body shots of the person.

  2. Use a maximum of 26 and a minimum of 4 pictures of your subject, preferably cropped to a 1:1 aspect ratio.

  3. Use 6 photos of the full body or entire object + 10 medium shot photos from the chest up + 10 close-ups.

  4. Variation is key — change body poses for every picture, and use pictures from different days, backgrounds, and lighting. Every picture of your subject should introduce new info about your subject.

  5. Avoid pictures taken at the same hour/day. On the other hand, a few pictures with the same shirt will make the model learn the shirt as well as part of the subject.

  6. Always pick a new background.

  7. Do not upload pictures mixed with other people.

  8. Do not upload funny faces.

However, as a developer, you would instead be using Astria.ai API to create the fine-tune. For that, here’s how you can send the equivalent API request to create your tune:

curl -X POST -H "Authorization: Bearer $YOUR_API_KEY" https://api.astria.ai/tunes \
 -F tune[title]="Lucky Blue Smith - UUID - 1234–6789–1234–56789" \
 -F tune[name]=man \
 -F tune[base_tune_id]=690204 \
 -F tune[token]=ohwx \
 -F tune[images][0]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Male/1.jpg" \
 -F tune[images][1]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Male/2.jpg" \
 -F tune[images][2]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Male/3.jpg" \
 -F tune[images][3]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Male/4.jpg"

Congratulations! You have created your first tune on Astria.ai. After that, you will see your created fine tunes, as shown in the example below:

Now, click on one of your created tunes that redirects you to the prompt for creating the image (based on your prompts). The screen will then open, as shown in the image below:

While fine-tuning the prompt, write a prompt to create the image you desire. We will stick with prompts that generate user images that don’t look fake to preserve the natural feel and authenticity desired for a genuine and approachable dating profile.

By focusing on prompts that emphasize everyday moments and genuine expressions, we can ensure that the images reflect the true essence of the individual. Each picture must tell a story of who ohwx man is, showcasing his interests and personality in a way that feels both real and engaging. The aim is to create a visual narrative that resonates with viewers, making them feel as if they’re catching a glimpse into his life, rather than viewing posed or artificial representations. This will help build a connection and attract others who appreciate the sincerity and unique character captured in his dating profile images.

For example, I used the following prompt to generate an image.:

Capture ohwx man enjoying a relaxed weekend stroll in a local park. He’s dressed in a comfortable, fitted t-shirt and classic jeans, with a pair of sunglasses casually pushed up into his hair. The background should be a soft focus of greenery and walking paths, suggesting an easygoing lifestyle and love for the outdoors.

Negative prompt:

over-processing, empty background, formal attire, glaring lights, exaggerated smiles

Alternatively, you can also send an API request to submit the prompt

curl -X POST -H "Authorization: Bearer $YOUR_API_KEY" https://api.astria.ai/tunes/1133109/prompts \
 -F prompt[text]="Capture ohwx man enjoying a relaxed weekend stroll in a local park. He's dressed in a comfortable, fitted t-shirt and classic jeans, with a pair of sunglasses casually pushed up into his hair. The background should be a soft focus of greenery and walking paths, suggesting an easygoing lifestyle and love for the outdoors." \
 -F prompt[negative_prompt]="over-processing, empty background, formal attire, glaring lights, exaggerated smiles" \
 -F prompt[super_resolution]=true \
 -F prompt[face_correct]=true

Generated Image:

Now, make sure to use ‘(ohwx man)’ in the prompt. This ensures that it recognizes that you have created this using your own fine-tuned model.

Let’s try another prompt to generate naturalistic-looking images.

Show ohwx man in a natural, unposed moment as he reads a book at a local café. He’s seated comfortably, engrossed in his book, wearing a light sweater. The café is softly blurred out, but there should be hints of a cozy atmosphere with a touch of urban flair.

Negative prompt:

over-processing, empty background, excessive filters, low-resolution

We made another tune of a female model as shown below:

curl -X POST -H "Authorization: Bearer $YOUR_API_KEY" https://api.astria.ai/tunes \
 -F tune[title]="Miranda Kerr - UUID - 1234–6789–1234–56789" \
 -F tune[name]=woman \
 -F tune[base_tune_id]=690204 \
 -F tune[token]=ohwx \
 -F tune[images][0]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Female/1.jpg" \
 -F tune[images][1]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Female/2.jpg" \
 -F tune[images][2]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Female/3.jpg" \
 -F tune[images][3]="@C:/Users/vardh/OneDrive/Documents/Astria_AI_Headshot/Pixabay_Model_3_Female/4.jpg"

Let’s try out a few prompts on this tune

Generate an image of ohwx woman taking a break on a bench in a city square, with a candid laugh as she watches something amusing out of frame. She’s wearing a smart-casual outfit suitable for the office or a date. The city environment should be lively but not overwhelming, with architectural features that add character without dominating the scene.

Negative prompt:

stereotypical props, awkward cropping, red-eye, flash photography, busy backgrounds

We’ll prompt our tune to generate something in a setting with Nature.

Present ohwx woman on a nature trail, captured in a moment where she’s observing the surroundings with a look of wonder or pointing at a bird or plant. She’s dressed in practical but stylish outdoor gear. The setting is a peaceful forest or nature reserve, conveying her appreciation for the environment and active hobbies.

Negative Prompt:

Silly outfit, Inauthentic pose, Empty settings, Low resolution, Multiple fingers

Via API request

curl -X POST -H "Authorization: Bearer $YOUR_API_KEY" https://api.astria.ai/tunes/1133109/prompts \
 -F prompt[text]="Present ohwx woman on a nature trail, captured in a moment where she's observing the surroundings with a look of wonder or pointing at a bird or plant. She's dressed in practical but stylish outdoor gear. The setting is a peaceful forest or nature reserve, conveying her appreciation for the environment and active hobbies." \
 -F prompt[negative_prompt]="Silly outfit, Inauthentic pose, Empty settings, Low resolution, Multiple fingers" \
 -F prompt[super_resolution]=true \
 -F prompt[face_correct]=true

When generating images using prompts, there are ‘Advanced’ and ‘Controlnet/Img2img’ settings. The platform offers advanced settings that allow you to fine-tune and customize your images for high-quality results. Let’s explore some of the key features of Astria.ai’s advanced settings:

Astria’s Advanced Settings for further refining user-generated images

Color Grading: Choose from various color grading options such as Film Velvia, Film Portra, and Ektar to enhance the mood and tone of your images. Experiment with different presets to achieve the perfect look for dating profiles.

Width and Height: Adjust the width and height of the generated image to ensure it meets specific requirements of users. Whether the need is for a square profile picture or a landscape banner image, the platform gives you full control over the dimensions.

Number of Images: Specify the number of images you want to generate at once, allowing users to create a variety of options to choose from for their dating profiles.

Film Grain: Add a touch of vintage charm to your images with the film grain feature, which simulates the texture and graininess of traditional film photography.

Super-Resolution: Enhance the resolution of your images with super-resolution technology, which increases the clarity and detail of your photos for stunning results.

Super-Resolution Details: Fine-tune the level of detail enhancement with super-resolution details settings, giving you control over the sharpness and clarity of your images.

Face Correct: Correct any facial distortions or abnormalities in your images with face-correct features, ensuring your appearance is accurately represented in your dating profile.

ControlNet/Img2img Settings

In addition to the advanced settings mentioned above, the platform also offers ControlNet/Img2Img settings for even greater control over your image editing process:

Img2img URL or Img2img File: Specify the img2img URL or upload an img2img file to use as a reference for generating your images.

Prompt Strength: Also known as denoising strength, adjust the prompt strength to control the balance between the input image and the prompt. A higher prompt strength value will prioritize the prompt, while a lower value will retain more of the input image characteristics.

With Astria.ai’s advanced and ControlNet/Img2Img settings, users can take their dating profile pictures to the next level, ensuring they stand out and make a lasting impression in the competitive world of online dating.

Here’s how you can leverage the API using NodeJs

// NodeJS 16
// With image_urls and fetch()
// For NodeJS 18 - do NOT import the below as it is built-in
import fetch from "node-fetch";
const API_KEY = 'sd_XXXXXX';
const DOMAIN = 'https://api.astria.ai';
function createTune() {
 let options = {
 method: 'POST',
 headers: { 'Authorization': 'Bearer ' + API_KEY, 'Content-Type': 'application/json' },
 body: JSON.stringify({
 tune: {
 "title": 'John Doe - UUID - 1234–6789–1234–56789',
 // Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes
 // https://www.astria.ai/gallery/tunes/690204/prompts
 "base_tune_id": 690204,
 "name": "cat",
 "branch": "fast",
 "image_urls": [
 "https://i.imgur.com/HLHBnl9.jpeg",
 "https://i.imgur.com/HLHBnl9.jpeg",
 "https://i.imgur.com/HLHBnl9.jpeg",
 "https://i.imgur.com/HLHBnl9.jpeg"
 ],
 "prompts_attributes": [
 {
 "text": "ohwx cat in space circa 1979 French illustration",
 "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1"
 },
 {
 "text": "ohwx cat getting into trouble viral meme",
 "callback": "https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=2"
 }
 ]
 }
 })
 };
 return fetch(DOMAIN + '/tunes', options)
 .then(r => r.json())
 .then(r => console.log(r))
}
createTune()

/// With form-data, fetch() and nested prompts
// For NodeJS 18 - do NOT import the two below as they are built-in
import fetch from "node-fetch";
import FormData from 'form-data';
import fs from 'fs';
const API_KEY = 'sd_XXXX';
const DOMAIN = 'https://api.astria.ai';
function createTune() {
 let formData = new FormData();
 formData.append('tune[title]', 'John Doe - UUID - 1234–6789–1234–56789');
 // formData.append('tune[branch]', 'fast');
 // Hard coded tune id of Realistic Vision v5.1 from the gallery - https://www.astria.ai/gallery/tunes
 // https://www.astria.ai/gallery/tunes/690204/prompts
 formData.append('tune[base_tune_id]', 690204);
 formData.append('tune[name]', 'man');
 formData.append('tune[prompts_attributes][0][callback]', 'https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1&prompt_id=1');
 formData.append('tune[prompts_attributes][0][input_image]', fs.createReadStream(`./samples/pose.png`));
 formData.append('tune[prompts_attributes][0][text]',"ohwx man inside spacesuit in space")
 // Load all JPGs from ./samples directory and append to FormData
 let files = fs.readdirSync('./samples');
 files.forEach(file => {
 if(file.endsWith('.jpg')) {
 formData.append('tune[images][]', fs.createReadStream(`./samples/${file}`), file);
 }
 });
 formData.append('tune[callback]', 'https://optional-callback-url.com/to-your-service-when-ready?user_id=1&tune_id=1');
 let options = {
 method: 'POST',
 headers: {
 'Authorization': 'Bearer ' + API_KEY
 },
 body: formData
 };
 return fetch(DOMAIN + '/tunes', options)
 .then(r => r.json())
 .then(r => console.log(r));
}
createTune();

The following parameters are essential for customizing the fine-tuning process within the Astria Dreambooth API:

- name: A descriptor for the fine-tune category, such as ‘man’, ‘woman’, ‘cat’, ‘dog’, ‘boy’, ‘girl’, or ‘style’.

- title: A unique identifier for the fine-tune session, typically a UUID corresponding to the specific transaction for idempotency purposes.

- images: A collection of images used to train the fine-tune. These can be provided either through multipart/form-data uploads or via image_urls.

- image_urls: A list of URLs pointing to images used for fine-tuning the model.

- callback: (Optional) The endpoint URL that will be called via POST request when fine-tuning is complete, delivering the tune object.

- branch: (Optional) Specifies the branch of the model to use, with options like ‘sd15’, ‘sdxl1’, or ‘fast’. Defaults to ‘base_tune’ or ‘sd15’ if ‘base_tune’ is unspecified.

- Note: Use branch=fast for testing purposes.

- steps: (Optional) Dictates the number of training steps. It is recommended to leave this unspecified to allow the system to set optimal defaults.

- token: (Optional) A unique token that embeds the fine-tuned features. Defaults are ‘ohwx’ for SDXL and ‘sks’ for SD15 models.

- face_crop: (Optional) If activated, the system will detect faces in the training images and expand the training set with the cropped faces, adhering to the account’s default settings.

- training_face_correct: (Optional) Activates GFPGAN to enhance training images, particularly useful if the source pictures are of low quality or resolution. This may result in an overly smooth appearance in some cases.

- base_tune_id: (Optional) Allows for additional training on top of an existing fine-tune or a different base model from the gallery, identified by the ID in its URL.

- model_type: (Optional) Defines the type of model adjustments to be used, with choices like ‘lora’, ‘pti’, ‘faceid’, or ‘null’ for a standard checkpoint. For SDXL1, the API defaults to ‘pti’ and disregards the model_type parameter.

- prompts_attributes: (Optional) An array of prompt entities complete with all attributes as defined in the prompt creation documentation.

For more information visit https://docs.astria.ai/docs/api

Conclusion

As a business in the online dating industry, standing out and attracting users is more challenging than ever. Profile photos are one of the most important factors in making a great first impression, yet finding high-quality, customized images can be time-consuming and expensive.

That’s why integrating Astria.ai’s state-of-the-art artificial intelligence into your platform is a game-changer. With just a few lines of code, you can give your users access to AI-generated profile photos that are indistinguishable from real ones.

Astria.ai’s flexible API allows you to easily build customized image generation into your existing workflows. Your users simply provide a text prompt and the AI creates stunning profile photos tailored to them.

The benefits don’t stop there. By providing a frictionless, engaging user experience you’ll boost conversion rates and retention.

As a pioneer in synthetic media, Astria.ai already powers many online businesses. Join the future of profile photos — integrate Astria.ai’s API today and watch your users take their profiles to the next level with AI-generated images.

Originally published on medium: https://medium.com/@shaikhrayyan123/the-ultimate-guide-to-generating-images-for-dating-profiles-with-stable-diffusion-on-astria-ai-31720925eca8

Did you find this article valuable?

Support Rayyan's Blog by becoming a sponsor. Any amount is appreciated!