The AI Art Generator App is an Android application that leverages the Stable Diffusion API to create unique artworks based on user-provided prompts. It follows the MVVM architecture pattern and uses Retrofit for API communication and Glide for efficient image loading.
- Android Studio with Kotlin support
- Knowledge of MVVM architecture
- Retrofit and Glide dependencies added to your project
-
Clone the repository:
git clone https://github.com/UmairOye/AI-Art-Generator.git cd AI-Art-Generator
-
Open the project in Android Studio.
-
Build and run the app on an emulator or physical device.
val artApi: ArtApi by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ArtApi::class.java)
}
interface ArtApi {
@POST("/api/v4/dreambooth")
fun makeApiRequest(@Body requestBody: DreamBoothRequest): Call<ApiResponse>
}
fun makeApiRequest(requestBody: DreamBoothRequest, onResponse: (ApiResponse?) -> Unit) {
val call = artApi.makeApiRequest(requestBody)
call.enqueue(object : Callback<ApiResponse> {
override fun onResponse(call: Call<ApiResponse>, response: Response<ApiResponse>) {
if(response.isSuccessful)
{
Log.d(TAG, "onResponse: ${response.body()!!.status}")
onResponse(response.body())
}else{
Log.d(TAG, "onResponse: not successful")
}
}
override fun onFailure(call: Call<ApiResponse>, t: Throwable) {
onResponse(ApiResponse(t.message.toString(), 0.0, 0, emptyList()))
}
})
}
Glide is used for efficient image loading. Here's an example of how to load an image into an ImageView:
Glide.with(this)
.load("https://example.com/image.jpg")
.into(imageView)
If you found this project useful or had fun exploring it, please consider giving it a star. It's a great way to show your appreciation and it puts a smile on my face! 😊🌟