0% found this document useful (0 votes)
22 views42 pages

Text and Image Synthesis System

The Mini Project Report details the development of a 'Text and Image Synthesis System' aimed at automating content creation using AI technologies like Gemini for text and Stability AI for images, integrated within a Flutter application. The project emphasizes user-friendly design, secure authentication via Firebase, and scalable data management through Firestore, addressing the challenges of traditional content creation methods. The report outlines the project's motivation, system analysis, implementation, and future scope, highlighting its potential impact across various industries.

Uploaded by

dizbyte.com
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views42 pages

Text and Image Synthesis System

The Mini Project Report details the development of a 'Text and Image Synthesis System' aimed at automating content creation using AI technologies like Gemini for text and Stability AI for images, integrated within a Flutter application. The project emphasizes user-friendly design, secure authentication via Firebase, and scalable data management through Firestore, addressing the challenges of traditional content creation methods. The report outlines the project's motivation, system analysis, implementation, and future scope, highlighting its potential impact across various industries.

Uploaded by

dizbyte.com
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

Belagavi, (State Technological University, Govt. of Karnataka)

Mini Project Report


On
“Text and Image Synthesis System”
Submitted in partial fulfilment of the requirements for the award of degree of
Bachelor of Engineering
In
Computer Science and Engineering

Submitted by:

Gurunath Gadigeppa Pujar 1JS21CS064


Harish J 1JS21CS065
Indraj V 1JS21CS071
K Sai Sree Akshaya Gurudatta 1JS21CS074

Under the Guidance of


Dr. K S Rajeshwari
Assistant Professor
Dept. of CSE, JSSATEB

JSS Academy of Technical Education,Bengaluru


Department of Computer Science & Engineering
2023 - 24
JSS ACADEMY OF TECHNICAL EDUCATION
JSSATE Campus, Uttarahalli-Kengeri Main Road, Bengaluru- 560060
Department of Computer Science & Engineering

CERTIFICATE

This is to certify that the Mini Project titled “Text and Image Synthesis System”
carried out by GURUNATH GADIGEPPA PUJAR (1JS21CS064),HARISH J
(1JS21CS065), INDRAJ V (1JS21CS071), K SAI SREE AKSHAYA GURUDATTA
(1JS21CS074) in partial fulfilment for the Mini Project (21CSMP67) of 6th
Semester Bachelor of Engineering in Computer Science and Engineering in
Visvesvaraya Technological University Belagavi during the year 2023-2024. It is
certified that all corrections and suggestions indicated for Internal Assessment have
been incorporated in the report. The mini project report has been approved as it
satisfies the academic requirement in respect of the project work prescribed for
the said degree.

________________ ________________
Dr. K S Rajeshwari Dr. P B Mallikarjuna
Assistant Professor HOD
Dept. of CSE, JSSATEB Dept. of CSE, JSSATEB
ACKNOWLEDGEMENT

This internship is the result of accumulated guidance, direction, and support from several
important individuals. We take this opportunity to express our gratitude to all who have helped
us complete the internship.

We express our sincere thanks to our Principal Dr. Bhimasen Soragaon providing us with
adequate facilities to undertake this internship.

We would like to thank our Head of Department, CSE, Dr. P.B Mallikarjuna for providing
us with the opportunity to carry out this internship and for his valuable guidance and support.

Our deep and profound gratitude goes to our guide, Dr. K S Rajeshwari, Assistant Professor,
for her keen interest and encouragement at every step in completing the internship.

We would like to express our deepest gratitude to our Mini Project Coordinators ,
Dr. Nagasundra K B and Dr. Pradeep H K , Department of Computer Science and
Engineering, for their invaluable guidance and support throughout our project.

We would also like to thank all the faculty members of our department for their support
throughout the internship.

Our thanks also go to the non-teaching members of our department for their assistance during
the internship.

Last but not least, we would like to thank our parents and friends, whose constant help made
the completion of this internship possible.

Gurunath Gadigeppa Pujar 1JS21CS064


Harish J 1JS21CS065
Indraj V 1JS21CS071
K Sai Sree Akshaya Gurudatta 1JS21CS074

i
ABSTRACT
In the contemporary digital age, the demand for personalized and dynamic content creation has
surged across various sectors, including marketing, education, and entertainment. Traditional
methods of content creation are often time-consuming and labor-intensive, posing significant
challenges in maintaining efficiency and consistency. This project aims to address these
challenges by developing an AI-powered generation app using Flutter and Dart, integrated with
advanced AI models such as Gemini for text generation and Stability AI for image generation.
The app also incorporates Firebase for secure user authentication and Firestore for scalable data
management.The proposed system leverages the strengths of each component to provide a
seamless and efficient solution for automated content creation. Flutter’s reactive framework
ensures a responsive and intuitive user interface, while Gemini and Stability AI offer powerful
AI capabilities for generating high-quality text and images from user prompts. Firebase
Authentication guarantees secure access management, and Firestore facilitates real-time data
synchronization and scalable storage.

This integration not only simplifies the content creation process but also enhances user
engagement by providing personalized and interactive content. The application is designed to be
highly scalable, secure, and user-friendly, making it suitable for a wide range of applications
across different industries. The project's future scope includes extending AI capabilities, adding
new features, improving user experience, and expanding market reach, positioning it as a
versatile tool for modern content generation needs.By addressing the limitations of existing
systems and leveraging state-of-the-art technologies, this project sets a new standard for content
generation applications, demonstrating the potential of combining advanced AI with robust
mobile and backend frameworks.

ii
Table of Content

Chapter Title Page No


Acknowledgement i
Abstract ii
Table of Content iii
Table of Figures iv

CHAPTER 1 INTRODUCTION…………………………………. 1
1.1 Motivation………………………………………. 1

CHAPTER 2 LITERATURE SURVEY…………………………. 3


2.1 Problem Statement…………………………….... 4

CHAPTER 3 SYSTEM ANALYSIS……………………………... 6


3.1 Existing Systems………………………………... 6
3.2 Proposed Systems………………………………. 7
3.3 Design…………………………………………... 9

CHAPTER 4 IMPLEMENTATION…………………………….. 14
4.1 Code Snippet…………………………………… 14
4.2 Snapshots……………………………………….. 23

CHAPTER 5 TESTING…………………………………………... 30
5.1 App Testing……………………………………... 30
5.2 API Testing…………………………………….... 31

CHAPTER 6 CONCLUSION…………………………………….. 32
6.1 Future Scope…………………………………….. 32
REFERENCES……………………………………... 34

iii
List of Figures

Fig No Title Page No


3.1 Automated content generation 7
3.2 Unified Data Integration 7
3.3 Firestore security rules for server-side clients 8
3.4 Flutter architecture 9
3.5 Firebase architecture with API and Frontend 10
3.6 Gemini VertexAI architecture 12
4.1 Flutter clean architecture 14
4.2 Login page & Register(Sign Up)page 15
4.3 Forgot password page & Password recovery mail 16
4.4 Reset password page & Login page 17
4.5 Home screen & Text sage page 17
4.6 Text Sage,Loading screen & Text generation pages 18
4.7 Image prompt & corresponding image generated-1 19
4.8 Image prompt & corresponding image generated-2 19
5.1 Flutter App Testing 20
5.2 Google CodeLab Gemini API Testing 21

iv
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 1
INTRODUCTION

In the rapidly evolving field of artificial intelligence, the demand for applications that harness
the power of AI to generate content is on the rise. Recognizing this need, we developed an
innovative AI generation application using Flutter and Dart. This application leverages
cutting-edge technologies to provide users with the ability to generate both text and images
from their prompts, offering a seamless and interactive user experience.The text generation
capability is powered by Gemini, a sophisticated AI model renowned for its natural language
processing prowess. This ensures that users receive high-quality, contextually appropriate
text based on their inputs. For image generation, we integrated Stability AI, a state-of-the-art
model that produces visually appealing and contextually relevant images from textual
descriptions.

To enhance the user experience and ensure security, we incorporated Firebase for
authentication. This allows users to create and manage accounts securely. Additionally, we
utilized Firestore, a flexible and scalable database, to store user credentials and other relevant
data, ensuring efficient data management and retrieval.This report provides a comprehensive
overview of the application’s architecture, the technologies used, and the development
process. It highlights the integration of AI models for content generation, the implementation
of authentication and data storage solutions, and the overall functionality of the application.
Through this report, we aim to showcase the potential of AI-driven content generation and
the robust capabilities of our application in meeting user needs.

1.1 Motivation
The motivation behind developing this AI generation application stems from the growing
need for dynamic and intelligent content creation tools in various fields. As technology
continues to advance, the demand for applications that can generate high-quality text and
images on demand has surged. This demand spans industries such as marketing,
entertainment, education, and more, where creativity and efficiency are paramount.

Empowering Creativity: In a world where content is king, empowering users to create


engaging and relevant content quickly is crucial. This application enables users to unleash

DEPT. OF CSE,JSSATEB 1
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

their creativity by providing a platform where they can generate unique text and images
effortlessly. Whether it's crafting compelling stories, designing captivating visuals, or
creating educational materials, the application opens up new avenues for creative expression.

Enhancing Productivity:Time is a valuable resource, and generating content manually can be


time-consuming. By automating the content generation process, the application significantly
enhances productivity. Users can quickly generate high-quality content, allowing them to
focus on other critical tasks and streamline their workflows.

Democratizing AI Technology:AI technology has traditionally been accessible primarily to


those with technical expertise. This application aims to democratize AI by making it
accessible to a broader audience. By providing an intuitive and user-friendly interface, it
allows individuals and businesses, regardless of their technical background, to leverage
advanced AI models for their content generation needs.

Fostering Innovation :The integration of state-of-the-art AI models, such as Gemini for text
generation and Stability AI for image generation, demonstrates the potential of AI in
transforming content creation. This application serves as a testament to the innovative
possibilities that arise from combining cutting-edge technology with practical applications,
inspiring further advancements in the field.

Ensuring Security and Scalability:With the inclusion of Firebase for authentication and
Firestore for data storage, the application not only provides a secure environment for users
but also ensures scalability to accommodate a growing user base. This robust infrastructure
reflects our commitment to delivering a reliable and secure solution that can evolve with the
needs of its users.

DEPT. OF CSE,JSSATEB 2
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 2
LITERATURE SURVEY

Paper 1: Supercharging Apps with Firebase and the Gemini API, February 2024
Personalized User Experiences:By leveraging the power of Gemini's natural language
processing and image generation, apps can deliver highly personalized content. For instance,
a conference assistant can suggest sessions based on user interests, making event navigation
easier and more engaging.
Real-time Interactions:Firebase’s real-time database capabilities ensure that user interactions
and data are updated instantly, allowing for seamless and interactive user experiences.
Scalability and Security:The combination of Firebase for authentication and Firestore for data
storage ensures that the application can scale to accommodate a large number of users while
maintaining robust security protocols to protect user data.
Ease of Integration:The research highlights the relatively straightforward process of
integrating the Gemini API with Firebase services, which allows developers to add
sophisticated AI features to their applications without extensive reconfiguration.

Paper 2: Building an AI Flutter Code Generator with Gemini. March 2024


Setup and Configuration:Detailed steps on cloning the project repository, installing necessary
dependencies, and configuring the Gemini API key within a Flutter environment. This
ensures that developers can quickly get started with the project setup.
Prompt Engineering:The tutorial emphasizes the importance of prompt engineering, showing
how to craft effective prompts to guide the AI in generating accurate and relevant code
snippets. This is crucial for achieving the desired outputs and enhancing the application's
functionality.
Customizability:Developers are guided on how to modify existing commands and prompts
to suit their specific needs, showcasing the flexibility of using Gemini for various coding
tasks.
Debugging and Testing:Instructions on running the project in debug mode within VS Code,
allowing developers to test and refine the generated code in a controlled environment. This
iterative process helps ensure that the application functions as intended and meets quality
standards.

DEPT. OF CSE,JSSATEB 3
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Paper 3: Flutter Generative AI App Using Gemini, March 2024


Development Environment:A step-by-step walkthrough of setting up the development
environment, including installing Flutter and Dart, configuring the Gemini API, and
preparing the project workspace. This foundational setup is crucial for smooth development.
Integration Techniques:The blog discusses various techniques for integrating Gemini’s text
and image generation capabilities into a Flutter application, with practical examples
demonstrating how to handle user inputs and generate corresponding outputs.
Use Cases and Applications:Real-world use cases are explored, such as generating story
content, creating visual art from descriptions, and building interactive educational tools.
These examples highlight the versatility and potential of combining Flutter with generative
AI.
Challenges and Solutions:The author shares personal experiences with common challenges
encountered during the integration process, such as handling API responses and managing
data flow within the app. Solutions and best practices are provided to help other developers
navigate similar issues.

2.1 Problem Statement


Automated Content Generation
Text Generation: Users require a reliable method to generate high-quality, contextually
relevant text based on specific prompts. Manual text creation is not only slow but also prone
to inconsistencies, especially when dealing with large volumes of content.
Image Generation: There is a need for a system that can create visually appealing images
from textual descriptions, which can be used in various applications such as marketing
materials, educational resources, and creative projects. Traditional graphic design processes
are often time-consuming and require specialized skills.

User Authentication and Data Security


Secure Authentication: Ensuring that users can securely access the application is crucial. This
involves managing user credentials, preventing unauthorized access, and protecting sensitive
information.
Scalable Data Storage: The application must be capable of storing and managing user data
efficiently. This includes handling user-generated content, maintaining data integrity, and
providing real-time data synchronization across different devices and platforms.

DEPT. OF CSE,JSSATEB 4
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Integration and Usability


Seamless Integration: Combining multiple advanced technologies such as AI models, mobile
development frameworks, and backend services can be complex. Ensuring that these
components work together seamlessly is essential for delivering a smooth user experience.
User-friendly Interface: The application should be intuitive and easy to use, allowing users
to interact with the AI features without needing extensive technical knowledge.

DEPT. OF CSE,JSSATEB 5
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 3
SYSTEM ANALYSIS

3.1 Existing systems


Manual Content Creation
Text Generation: Content creators manually write text, which can be time-consuming and
inconsistent. This process requires significant effort and skill, especially when generating
large volumes of content or maintaining a consistent style across different pieces.
Image Creation: Graphic designers manually create images using software like Adobe
Photoshop or Illustrator. This process requires specialized skills and can be labor-intensive,
limiting the speed and scalability of image production.

Disparate Tools and Technologies


Separate Systems: Existing solutions often involve using separate tools for text and image
generation, such as word processors for text and graphic design software for images. This
fragmentation leads to inefficiencies and difficulties in maintaining coherence between text
and visual content.
Limited Integration: Tools for content generation and user management (e.g., authentication,
data storage) are often not integrated. This lack of integration can result in a disjointed user
experience and increased complexity in managing and synchronizing data across different
systems.

Security and Scalability Issues


Authentication: Existing systems may use basic authentication mechanisms that are not
robust enough to handle large user bases securely. This can lead to vulnerabilities and
potential data breaches.
Data Management: Traditional databases might struggle with real-time data synchronization
and scalability, leading to delays and inconsistencies in data access and storage, particularly
in applications with high user engagement.

DEPT. OF CSE,JSSATEB 6
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

3.2 Proposed systems

Fig 3.1 Automated content generation


Fig 3.1 explains the automated process of content generation which is explained in details in
the following paragraph.
Automated Content Generation
Gemini for Text Generation: Integrating Gemini's advanced natural language processing
capabilities to automate the generation of high-quality, contextually relevant text based on
user prompts. This reduces the time and effort required for manual text creation while
ensuring consistency and coherence.
Stability AI for Image Generation: Utilizing Stability AI's state-of-the-art image generation
models to create visually appealing images from textual descriptions. This automates the
image creation process, enabling users to quickly produce high-quality visuals without
requiring specialized design skills.

Fig 3.2 Unified Data Integration

DEPT. OF CSE,JSSATEB 7
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 3.2 explains the integration process of the content generated which is explained in details
in the following paragraph.
Unified and Integrated Tools
Seamless Integration: The proposed system leverages Flutter and Dart to create a unified
application that integrates text and image generation capabilities. This provides a seamless
user experience, allowing users to generate and manage content from a single platform.
Backend Services: By incorporating Firebase for authentication and Firestore for data
storage, the proposed system ensures that user data is managed securely and efficiently. These
services provide real-time data synchronization and robust security features, enhancing the
overall functionality and reliability of the application.

Fig 3.3 Firestore security rules for server-side clients


Fig 3.1 explains the rules and data flow of the authentication process which is explained in
details in the following paragraph.
Enhanced Security and Scalability
Firebase Authentication: Implementing Firebase Authentication to provide a secure and
scalable solution for user authentication. This ensures that user credentials are protected and
that the system can handle a growing user base without compromising security.
Firestore Database: Using Firestore to store and manage user data, offering real-time
synchronization and scalable data management. This ensures that data is consistently
available and up-to-date, even in applications with high levels of user engagement.

DEPT. OF CSE,JSSATEB 8
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

3.3 Design
Flutter Architecture

Fig 3.4 Flutter architecture


Fig 3.4 represent the complete architecture of Flutter.Flutter architecture is designed to enable
high-performance, high-fidelity mobile applications using a reactive framework. The
architecture consists of several key layers:

Flutter Engine
Rendering: The engine uses Skia for rendering 2D graphics. It renders the UI, manages
animations, and handles the interaction between the app and the device.
Platform Channels: This allows communication between Dart and the platform-specific code
(iOS/Android), enabling the integration of native functionalities such as sensors, camera, and
network.

Framework
Widgets: The building blocks of a Flutter app. Widgets describe the structure, style, and
layout of the UI. Everything in Flutter is a widget, from layout elements like rows and
columns to buttons and text.
Dart: Flutter uses the Dart programming language, which is optimized for building UIs.
Dart’s Just-in-Time (JIT) compilation allows for a fast development cycle with hot reload,
while Ahead-of-Time (AOT) compilation ensures high performance in production.

DEPT. OF CSE,JSSATEB 9
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

State Management
Provider: A commonly used package for state management in Flutter. It helps in managing
the state and rebuilding the UI efficiently based on state changes.
Bloc: Another popular state management solution which uses the concept of streams to
manage state and separate business logic from UI.

Material and Cupertino Libraries


These libraries provide a rich set of pre-designed widgets that adhere to the Material Design
guidelines (Android) and Cupertino design principles (iOS), ensuring a native look and feel
across platforms.

Firebase Architecture

Fig 3.5 Firebase architecture with API and Frontend

DEPT. OF CSE,JSSATEB 10
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 3.5 represent the complete architecture of Firebase.Firebase provides a comprehensive


suite of backend services and tools designed to help developers build and scale applications
quickly. The architecture comprises several core components:

Authentication
User Management: Provides methods for user authentication and management, including
email/password login, OAuth providers like Google and Facebook, and anonymous sign-in.
Security: Ensures secure authentication with built-in security practices and integration with
other Firebase services.

Firestore
Real-time Database: A NoSQL cloud database to store and sync data for client- and server-
side development. Firestore offers real-time synchronization, enabling data to be instantly
available across devices.
Scalability: Designed to handle large amounts of data and high traffic, making it suitable for
applications with a large user base.

Cloud Functions
Serverless Compute: Allows running backend code in response to events triggered by
Firebase features and HTTPS requests. This enables extending app functionality without
managing servers.

Cloud Storage
File Storage: Provides secure file uploads and downloads for app assets, user-generated
content, and more. It integrates with Firebase Authentication to enforce access control.

Analytics and Monitoring


Performance Monitoring: Tracks performance issues in real-time to help optimize the app.
Crashlytics: Provides detailed crash reports and analytics to help maintain app stability and
performance.

DEPT. OF CSE,JSSATEB 11
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Gemini Architecture

Fig 3.6 Gemini VertexAI architecture


Fig 3.6 represent the complete architecture of Gemini.Gemini, an advanced AI model
developed by Google, integrates multiple modalities such as text and images. Its architecture
focuses on providing versatile and high-performance AI capabilities. The key components
include:

Transformer-based Model
Multi-head Attention: Uses multiple attention mechanisms to understand different aspects of
the input data. This allows the model to capture complex relationships in the data.
Encoder-Decoder Structure: For tasks involving sequence-to-sequence prediction, such as
text generation. The encoder processes the input data, and the decoder generates the output
sequence.

Multimodal Capabilities
Text and Image Processing: Gemini can handle both text and image inputs, enabling it to
perform tasks like generating images from text descriptions or understanding context from
visual and textual data.
Unified Architecture: Combines vision and language understanding within a single model,
allowing for more coherent and contextually aware outputs.

DEPT. OF CSE,JSSATEB 12
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Training and Fine-tuning


Large-scale Pretraining: Gemini is pretrained on vast amounts of data to learn general
language and vision patterns.
Task-specific Fine-tuning: The model is fine-tuned on specific datasets related to the
application to enhance performance on particular tasks, such as text generation or image
captioning.

Integration with APIs


API Access: Gemini can be accessed through APIs, allowing developers to integrate its
capabilities into various applications. The API provides endpoints for generating text,
creating images, and other AI-driven functionalities.

DEPT. OF CSE,JSSATEB 13
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 4
IMPLEMENTATION
4.1 Code Snippet

Fig 4.1 Flutter clean architecture

The Fig 4.1 explains the Flutter’s Clean Architecture which aims to organize code in a way
that promotes separation of concerns and maintainability. It typically involves dividing the
project into three main layers:

DEPT. OF CSE,JSSATEB 14
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Presentation Layer
Contains UI-related code like widgets and screens.Uses providers or bloc/cubit for state
management.The lib/auth_pages and lib/pages directories in your project hold the different
screens and UI elements.

Domain Layer
Holds business logic and application rules.Contains use cases or interactors which are the
primary operations the app can perform.This layer is not explicitly shown in the project
structure but can be included in a directory for domain-related classes.

Data Layer
Manages data from various sources like remote APIs, local databases, etc.Contains
repositories and data providers.In your project, the lib/api and lib/firebase directories manage
API calls and Firebase integration.

Additional concepts often include


Entities: Core classes representing data structures.
Repositories: Interfaces for data access, implemented by specific data sources.
Use Cases: Encapsulate individual operations or business logic.

4.1.1 Main.dart
import 'package:ai_generative_app/auth_pages/login_screen.dart';
import 'package:firebase_core/firebase_core.dart';
//flutter
import 'package:flutter/material.dart';

//firebase
import 'firebase/firebase_options.dart';

Future<void> main() async {


WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
runApp(const MyApp());
}

DEPT. OF CSE,JSSATEB 15
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

class MyApp extends StatelessWidget {


const MyApp({super.key});

@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: LoginPage(),
);
}
}

The above code contains the Flutter application that initializes Firebase and sets up the main
entry point. It imports necessary packages, ensures Flutter binding is initialized, and
initializes Firebase with the platform-specific options. The ‘MyApp’ class extends
‘StatelessWidget’ and builds a ‘MaterialApp’ with ‘LoginPage’ as the home screen, while
also disabling the debug banner.

4.1.2 Firebase
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
return web;}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
return macos;
case TargetPlatform.windows:
return windows;

DEPT. OF CSE,JSSATEB 16
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.');
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);}}
static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyAwC-sGOXR9ZihufMF5XzbYN-IS5yWhbUw',
appId: '1:292180983689:android:cafaf6bcfe62cd04d9ab58',
messagingSenderId: '292180983689',
projectId: 'aigen-3c81e',
storageBucket: 'aigen-3c81e.appspot.com');

Above code contains the code that defines the ‘DefaultFirebaseOptions’ class, which
provides platform-specific Firebase configuration options. The ‘currentPlatform’ getter
returns the appropriate ‘FirebaseOptions’ based on the platform the app is running on, such
as web, Android, iOS, macOS, or Windows. It throws an ‘UnsupportedError’ for unsupported
platforms like Linux.

4.1.3 Database.dart – FireStore

import 'package:cloud_firestore/cloud_firestore.dart';
class DatabaseMethods {
Future addUser(String userId, Map<String, dynamic> userInfoMap) {
return FirebaseFirestore.instance
.collection("User")
.doc(userId)
.set(userInfoMap);
}
}
The above code contains the code which defines a ‘DatabaseMethods’ class with a method
‘addUser’ that adds a user's information to a Firestore database. The ‘addUser’ method takes

DEPT. OF CSE,JSSATEB 17
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

a ‘userId’ and a ‘userInfoMap’ containing user details, then stores this information in the
"User" collection under the document with the given ‘userId’

4.1.4 Authmanage.dart – AuthMethods

class AuthMethods {
final FirebaseAuth auth = FirebaseAuth.instance;
getCurrentUser() async {
return auth.currentUser;}
signInWithGoogle(BuildContext context) async {
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn();
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn();
final GoogleSignInAuthentication? googleSignInAuthentication =
await googleSignInAccount?.authentication;
final AuthCredential credential = GoogleAuthProvider.credential(
idToken: googleSignInAuthentication?.idToken,
accessToken: googleSignInAuthentication?.accessToken);
UserCredential result = await firebaseAuth.signInWithCredential(credential);
User? userDetails = result.user;
Map<String, dynamic> userInfoMap = {
"email": userDetails!.email,
"name": userDetails.displayName,
"imgUrl": userDetails.photoURL,
"id": userDetails.uid
};
await DatabaseMethods().addUser(userDetails.uid, userInfoMap).then((value) {
Navigator.push(
context, MaterialPageRoute(builder: (context) => const HomePage()));});}}

The above code contains the ‘AuthMethods’ class handles authentication in a Flutter app
using Firebase and Google Sign-In. The ‘getCurrentUser’ method returns the current
authenticated user. The ‘signInWithGoogle’ method initiates Google Sign-In, retrieves
authentication credentials, and signs in the user with Firebase. After signing in, it stores the

DEPT. OF CSE,JSSATEB 18
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

user's information in Firestore using the ‘DatabaseMethods’ class, and then navigates to the
‘HomePage’.

API
4.1.5 Stable Diffusion AI - ConvertTextToImage Future Function

Future<dynamic> convertTextToImage(
String prompt,
BuildContext context,
) async {
Uint8List imageData = Uint8List(0);
const baseUrl = 'https://api.stability.ai';
final url = Uri.parse(
'$baseUrl/v1alpha/generation/stable-diffusion-512-v2-1/text-to-image');
final response = await http.post(
url,headers: {
'Content-Type': 'application/json',
'Authorization':
//add ypur secreat key here
'Bearer sk-JgvQ5MbtO0hwwqZUUtRimX80w4nubxAcv1RI3ng3LE92HTUT',
'Accept': 'image/png',},
body: jsonEncode({
'cfg_scale': 15,
'clip_guidance_preset': 'FAST_BLUE',
'height': 512,
'width': 512,
'samples': 1,
'steps': 150,
'seed': 0,
'style_preset': "3d-model",
'text_prompts': [
{
'text': prompt,
'weight': 1,
}],}));

DEPT. OF CSE,JSSATEB 19
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

The above code explains the function, ‘convertTextToImage’, sends a POST request to the
Stability AI API to generate an image based on the provided text prompt. It constructs the
request with specific parameters and headers, including an authorization key. If the
response is successful, it navigates to the ‘ImageSecPage’ with the generated image;
otherwise, it shows an error dialog.

4.1.6 GeminiAI - GeminiAi Future Function

import 'package:ai_generative_app/constants/pallete.dart';
import 'package:ai_generative_app/pages/text_sec_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gemini/flutter_gemini.dart';
class TextGenPage extends StatefulWidget {
const TextGenPage({super.key});
@override
State<TextGenPage> createState() => _TextGenPageState();}
Future<String> geminiAi() async {
Gemini.init(apiKey: 'AIzaSyCBmxBxxwFm_QbiIUBH9ESFItIFX8Ch2xw');
final gemini = Gemini.instance;
try {
final response = await gemini.text(aiEditingController.text);
return response?.output ?? 'No output from Gemini';
} catch (e) {
return 'Error: $e';
}}

The above code explains the code that defines a ‘TextGenPage’ widget in Flutter, which is a
stateful widget for text generation. The ‘geminiAi’ function initializes the Gemini AI with
an API key and sends a text request using the input from ‘aiEditingController’. It returns
the response from Gemini AI or an error message if the request fails.

DEPT. OF CSE,JSSATEB 20
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

PAGES
4.1.7 Home screen
import 'package:flutter/material.dart';
import 'package:ai_generative_app/pages/image_gen_page.dart';
import 'package:ai_generative_app/pages/text_gen_page.dart';
import 'package:lottie/lottie.dart';
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Chat Sage')),
body: Column(
children: [
Lottie.asset('assets/ai_animation.json'),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildNavButton(context, Icons.text_fields_rounded, 'Text', TextGenPage()),
_buildNavButton(context, Icons. image_search_rounded, 'Image', ImageGenPage()),
],
),
],
),
);
}
The above code contains the code that defines a HomePage widget with an ‘AppBar’ and a
Column containing a Lottie animation and navigation buttons. Each button, created by
‘_buildNavButton’, navigates to a different page (TextGenPage or ImageGenPage) when
tapped. The buttons display an icon and label, with a consistent design using Container and
InkWell for tap detection.

DEPT. OF CSE,JSSATEB 21
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

4.1.8 Text generation page

class _TextGenPageState extends State<TextGenPage> {


final TextEditingController _controller = TextEditingController();
final FocusNode _focusNode = FocusNode();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Text Sage')),
body: GestureDetector(
onTap: () => _focusNode.unfocus(),
child: Padding(
padding: EdgeInsets.all(20),
child: Column(
children: [
TextField(
controller: _controller,
focusNode: _focusNode,
decoration: InputDecoration(
hintText: "What's on your mind today?",
suffixIcon: IconButton(
icon: Icon(Icons.search),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => TextSecPage()),
);

The above code contains the flutter code defines a stateful widget for a page with a text
input field.The ‘TextField’ uses a ‘TextEditingController’ and ‘FocusNode’ to manage its
state and focus. When the user taps outside the ‘TextField’, it loses focus. The ‘AppBar’
displays a title, and a ‘GestureDetector’ dismisses the keyboard on taps. The ‘TextField’
includes a suffix icon that navigates to a new page (TextSecPage) when pressed.

DEPT. OF CSE,JSSATEB 22
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

4.1.9 Image generation page

class _ImageGenPageState extends State<ImageGenPage> {


final textController = TextEditingController();
bool isLoading = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Image Sage')),
body: Padding(
padding: EdgeInsets.symmetric(horizontal: 20).copyWith(top: 50),
child: Column(
children: [
TextField(
controller: textController,
decoration: InputDecoration(
hintText: 'Enter your prompt',
fillColor: Colors.white,
filled: true,
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),),),
SizedBox(height: 30),
SizedBox(
width: 250,
height: 60,
child: ElevatedButton(
onPressed: () {
setState(() {
isLoading = true;
convertTextToImage(textController.text, context);
});
},
child: isLoading
? Lottie.asset('assets/img_animation.json')
: Text('Generate'),
),

DEPT. OF CSE,JSSATEB 23
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

),
],
),
),
);
The above code contains the flutter code which defines a stateful widget with a text input
field and a button. The ‘TextField’ allows users to enter a prompt, and the button triggers
image generation when pressed. If the button is pressed, it sets ‘isLoading’ to true and calls
‘convertTextToImage’. The button displays an animation if ‘isLoading’ is true; otherwise, it
shows a "Generate" label. The ‘AppBar’ displays the title "Image Sage," and the overall
layout is managed with padding and spacing.

DEPT. OF CSE,JSSATEB 24
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

4.2 Snapshots

Fig 4.2 Login page & Register(Sign Up)page

Fig 4.12 depict the login and registration screens of the app.
Login Screen:
Features input fields for email and password, with options to show/hide the
password.Includes buttons for signing in, resetting the password, and registering a new
account.

Registration (Sign Up) Screen:


Provides fields for email, mobile number, password, and password confirmation.

DEPT. OF CSE,JSSATEB 25
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.3 Forgot password page & Password recovery mail

Fig 4.13 depict the Forgot Password Screen of your app and Gmail-recovery mail
Forgot Password Screen:
Features input fields for email , with Send Email Button and Create a new Account option

Gmail-recovery mail:
Provides a link to change our current password.

DEPT. OF CSE,JSSATEB 26
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.4 Reset password page & Login page

Fig 4.14 depict the Reset Password Page and Login Screen of the app
Reset Password Page:
Features input fields for new password with save Button.

Login Screen:
Entering User Credentials with new password.

DEPT. OF CSE,JSSATEB 27
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.5 Home screen & Text sage page

Fig 4.15 depict the Chat Sage HomePage and Text Sage Page of the app
Chat Sage HomePage:
Features an welcome animation with two buttons named Text and Image.

Text Sage Page:


Input field with hint text to enter user's prompt.

DEPT. OF CSE,JSSATEB 28
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.6 Text Sage,Loading screen & Text generation pages

Fig 4.16 depict the Text Sage Page,Loading Screen,Text Page of the app
Text Sage Page:
Input field with user's prompt.

Loading Screen:
featuring a lottie animation instead of Circular loader until text generates.

Text Page:
Generated Text Displayed with toolbar options.

DEPT. OF CSE,JSSATEB 29
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.7 Image prompt & corresponding image generated - 1

Fig 4.17 depict the Image Sage Page, Image Page of the app
Image Sage Page:
Input field with user's prompt.

Image Page:
Generated Image Displayed.

DEPT. OF CSE,JSSATEB 30
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Fig 4.8 Image prompt & corresponding image generated - 2

Fig 4.18 depict the Image Sage Page, Image Page of the app
Image Sage Page:
Input field with user's prompt.

Image Page:
Generated Image Displayed.

DEPT. OF CSE,JSSATEB 31
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 5
TESTING

5.1 App Testing

Fig 5.1 Flutter App Testing


This Fig 5.1 provides a comprehensive overview of testing strategies in Flutter. It emphasizes
the importance of testing in maintaining app quality and reducing errors. The article explains
three primary types of tests: unit tests, widget tests, and integration tests.

1. Unit Tests: These tests validate individual functions or methods in isolation. They are quick
to run and help ensure that the logic of the app is correct.
2. Widget Tests: These tests focus on individual widgets and their interactions. They check how
widgets behave and render, ensuring that the UI components work as intended.
3. Integration Tests: These tests assess the app's overall functionality by simulating real user
interactions. They are slower but crucial for testing the entire app flow and verifying that all
components work together.

It also highlights best practices for writing effective tests, such as ensuring tests are
independent, using mock data, and following a consistent structure. By employing these
testing strategies, developers can identify issues early, improve app reliability, and enhance
the overall user experience.

DEPT. OF CSE,JSSATEB 32
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

5.2 API Testing

Fig 5.2 Google CodeLab Gemini API Testing


Fig 5.2 provide the dataflow arcjitecture of Gemini API.The Google CodeLab on Gemini API
Testing provides a comprehensive introduction to testing APIs using Google's Gemini
framework. It guides developers through the process of setting up a testing environment,
configuring API endpoints, and writing test cases. Key highlights include:
1. Setup: Instructions for installing and configuring the Gemini framework in a Java
development environment.
2. Writing Tests: Detailed steps on how to create and structure test cases to validate API
responses, including status codes and data accuracy.
3. Assertions: Techniques for asserting expected outcomes, such as response times and data
content.
4. Mocking: Guidance on using mocking to simulate API responses for robust testing.
5. Execution: How to execute tests and interpret the results to ensure API reliability.
6. Integration: Integrating Gemini tests into CI/CD pipelines for automated testing.
The CodeLab emphasizes best practices in API testing and demonstrates how Gemini can
streamline the process of verifying API functionality and performance.

DEPT. OF CSE,JSSATEB 33
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Chapter 6
CONCLUSION

The development of an AI generation app using Flutter and Dart, integrated with Gemini for
text generation and Stability AI for image generation, represents a significant advancement
in automated content creation. This project addresses key challenges in the existing systems
by leveraging advanced AI models and robust backend services to provide a seamless,
efficient, and secure solution.By utilizing Firebase for authentication and Firestore for data
storage, the application ensures secure user management and scalable data handling. The
integration of Gemini's natural language processing and Stability AI's image generation
capabilities allows for the automated creation of high-quality, contextually relevant text and
visually appealing images. This significantly reduces the time and effort required for content
creation, enhancing productivity and creativity.

The proposed system's architecture, combining Flutter’s reactive framework, Firebase’s


comprehensive backend services, and Gemini’s multimodal AI capabilities, provides a
cohesive and powerful tool for developers and users alike. This integration not only simplifies
the development process but also ensures a consistent and engaging user experience.Overall,
this project demonstrates the potential of combining state-of-the-art AI technologies with
modern development frameworks to create innovative applications that meet the growing
demands for personalized and dynamic content. It sets a new standard for content generation
applications, offering a scalable, secure, and user-friendly solution that can be adapted for
various use cases across different industries.

6.1 Future scope


Enhanced AI Capabilities
Advanced NLP and Image Models: Integrate newer versions of Gemini and Stability AI
models as they are developed. This will continuously improve the quality of generated text
and images, keeping the application at the forefront of AI technology.
Multilingual Support: Extend text generation capabilities to support multiple languages,
making the application accessible to a global audience and enhancing its utility across
different regions and cultures.

DEPT. OF CSE,JSSATEB 34
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

Additional Features
Voice Input and Output: Implement speech-to-text for input prompts and text-to-speech for
generated content, providing a more interactive and accessible user experience.
Custom Templates and Styles: Allow users to define custom templates and styles for
generated content, offering more personalization and control over the output.
Interactive Storytelling: Develop features for creating interactive stories or scenarios where
users can influence the storyline through their inputs, leveraging both text and image
generation.

Integration with Other Services


Cloud Integration: Expand integration with other cloud services such as AWS, Google Cloud,
or Microsoft Azure to offer more storage options, computational power, and additional APIs.
Third-Party APIs: Incorporate third-party APIs for additional functionalities like sentiment
analysis, language translation, and image recognition, providing richer content generation
capabilities.

Improved User Experience


Enhanced UI/UX: Continuously refine the user interface and user experience based on user
feedback, making the app more intuitive and easier to use.
Offline Capabilities: Develop features that allow users to access and use the app’s core
functionalities offline, syncing data when connectivity is restored.

Security and Compliance


Data Privacy: Implement advanced data privacy features to comply with global standards
such as GDPR and CCPA, ensuring user data is protected and user trust is maintained.
Authentication Methods: Explore and integrate more robust authentication methods such as
biometric authentication (fingerprint, facial recognition) for enhanced security.

DEPT. OF CSE,JSSATEB 35
TEXT AND IMAGE SYNTHESIS SYSTEM 2023-24

REFERENCES

[1] Mangirdas Kazlauskas,”How to create a generative AI app using Gemini and


Flutter”,March 12, 2024
https://kazlauskas.dev/blog/flutter-generative-ai-app-using-gemini/
[2] Joe Fernandez, “Build an AI Flutter code generator with Gemini”,28 Mar 2024
https://ai.google.dev/gemini-api/tutorials/flutter-theme-agent
[3] Alexander Nohe,Frank van Puffelen,”Supercharge your apps with Firebase and the
Gemini API”,February 15, 2024
https://firebase.blog/posts/2024/02/supercharge-apps-firebase-gemini
[4] Nidhi Sorathiya,”How To Create Fluent User Experiences With Flutter Textfields”,
May 11, 2024
https://www.dhiwise.com/post/how-to-create-fluent-user-experiences-with-flutter-
textfields
[5] Nidhi Sorathiya,”How to Integrate Google Generative AI into Your Flutter Projects:
An Essential Guide”,Feb 27, 2024
https://www.dhiwise.com/post/how-to-integrate-google-generative-ai-into-your-
flutter-projects
[6] Karl Mathuhu,” A Flutter Package for Image Generation using Stability API”,
Aug 22, 2023
https://flutterawesome.com/a-flutter-package-for-image-generation-using-stability-
api/
[7] Jumei Lin,”Flutter & Firebase App Tutorial — Part 1 Get Started”,Oct 17, 2021
https://medium.com/@lumeilin301/flutter-firebase-app-tutorial-part-1-get-started-
95cce84939c3
[8] Vijay R,”Lottie Animations in Flutter | Easy Integration | Flutter Animations”,Apr 16,
2023
https://medium.com/vijay-r/lottie-animations-in-flutter-2e80e41bbb63

DEPT. OF CSE,JSSATEB 36

You might also like