본문 바로가기
프로그램 활용/인공지능(AI)

[AI][기고] Stable Diffusion: 델파이로 내 PC에서 구현되는 생성형 AI

by 3604 2023. 9. 5.
728x90

출처: Stable Diffusion: 델파이로 내 PC에서 구현되는 생성형 AI - [기술 기고 게시판] 델파이, C++빌더, RAD 스튜디오 - 데브기어 포럼 (devgear.co.kr)

Welcome, art enthusiasts, developers, and innovators! Generative AI is turning into a powerful force in the software development and content creation spaces. In this article we will explore the Stable Diffusion Desktop client – a desktop UI designed to give you access to a whole host of Stable Diffusion models for image generation without having to have a GPU on your Windows, macOS, or Linux machine. Additionally,  it provides access to upscaling models to supersize the images you create.

생성형 AI는 소프트웨어 개발과 콘텐츠 제작 분야에서 강력한 힘을 발휘하고 있다. 이번 글에서는 스테이블 디퓨전 데스크탑(Stable Diffusion Desktop) 클라이언트를 살펴본다. 스테이블 디퓨전 데스크탑은 윈도우, macOS, 리눅스 머신에서 GPU 없이도 이미지를 생성할 수 있는 다양한 스테이블 디퓨전 모델에 접근 가능하도록 설계된 데스크탑 UI이다. 또한 생성한 이미지를 확대할 수 있는 업스케일링 모델에 액세스할 수도 있다.

 

목차


 

생성형 AI란?

Generative AI refers to a subset of artificial intelligence models that can produce new, previously unseen content by learning from a set of data. Rather than just making decisions based on existing information, generative models can create data that mirrors, in structure and style, the original dataset. These models are often used in tasks such as generating images, music, text, or even video based on patterns they’ve identified during their training phase.

생성형 AI는 데이터를 학습하면서 이전에는 볼 수 없던 새로운 콘텐츠를 생성하는 인공지능 모델들 중 하나이다. 단순히 기존 정보를 기반으로 의사 결정을 내리는 것이 아니라, 원본 데이터의 구조와 스타일을 모방한 데이터를 생성할 수 있는 것이다. 이러한 모델은 학습 단계에서 확인한 패턴을 기반으로 이미지, 음악, 텍스트, 동영상 생성 등의 작업에 주로 사용된다.

The underlying principle for most generative models is the idea of understanding and capturing the distribution of the input data. Techniques like Generative Adversarial Networks (GANs) and Variational Autoencoders (VAEs) are popular methodologies in this domain. With the rise of deep learning, generative AI has seen significant advancements, leading to innovations like realistic image generation, content creation, and even aiding drug discovery.

대부분 생성형 모델의 기본 원리는 입력 데이터의 분포를 이해하고 포착해내는 것이다. 생성적 대립 신경망(GANs, Generative Adversarial Networks)과 변이형 오토 인코더(VAEs, Variational Autoencoders) 등의 기법들은 이 분야에서 많이 사용되고 있는 방법론이다. 딥러닝이 급부상하면서 생성형 AI가 급격하게 발전하게되고 사실적인 이미지 생성, 콘텐츠 제작, 심지어 신약 개발 지원 등의 혁신으로까지 이어지고 있다.

 

스테이블 디퓨전(Stable Diffusion)이란?

Stable Diffusion, introduced in 2022, is a generative AI text-to-image deep learning model based on diffusion techniques. The model primarily translates text descriptions into detailed images. The model’s architecture is publicly available, making it distinct from other cloud-only models like DALL-E and Midjourney. A whole host of community trained models have sprung up around Stable Diffusion enhancing it and the images it can create.

2022년 소개된 스테이블 디퓨전은 확산 기법을 기반으로 한 생성형 AI 텍스트-이미지 딥 러닝 모델이다. 주로 텍스트 설명을 상세한 이미지로 바꿔준다. 해당 모델의 아키텍처는 공개적으로 오픈되어 있으며, DALL-E나 Midjourney 등 다른 클라우드 전용 모델과는 차별화되는 부분들이 있다. 스테이블 디퓨전을 중심으로 다양한 훈련 모델들이 등장하면서 더불어 같이 향상되고 생성 가능한 이미지의 다양성이 높아지고 있다.

This deep generative neural network uses a latent diffusion model, with its underlying technology involving the iterative denoising of noise, guided by a text encoder, to produce the desired image. A notable characteristic of Stable Diffusion is its ability to run on consumer GPUs, unlike other heavyweight models. There have been a number of releases of Stable Diffusion which have increased the training image size from 512×512 (Stable Diffusion 1.5) to 1024×1024 (SDXL).

이러한 심층 생성 신경망은 잠재 디퓨전 모델을 사용하는데, 텍스트 인코더 안내에 따라 반복되는 노이즈를 제거하는 기본 기술을 적용해 원하는 이미지를 생성할 수 있다. 스테이블 디퓨전의 주목할 만한 특징 중 하나는 다른 모델들은 무거운 것과는 달리, 일반 소비자용 GPU에서도 작동 가능하다는 점이다. 스테이블 디퓨전은 여러 번의 릴리스를 통해 훈련 이미지 크기를 512×512(Stable Diffusion 1.5)에서 1024×1024(SDXL)로 늘려왔다.

 

스테이블 디퓨전 데스크탑 클라이언트에서 활용 가능한 모델

사용자들은 다음과 같은 다양한 스테이블 디퓨전 모델을 사용할 수 있다:

  • Stable Diffusion 1.5
  • SDXL
  • DreamShaper
  • Realistic Vision v5.1
  • PortraitPlus
  • OpenJourney
  • Stable Diffusion 2.1
  • Edge of Realism … 등등

 

해상도를 높이는(Upscaling) 기능이 필요하다면? 클라이언트에서 제공하는 도구들

클라이언트로 제작뿐 아니라 향상도 가능하다. 다음의 통합 도구를 제공한다:

  • Codeformer (facefix)
  • Real-ESRGAN (facefix)
  • Swin2SR
  • GFPGAN (facefix)
  • Swinir
  • Rundalle-sr
  • Esrgan … 등등

 

크로스 플랫폼 호환이 가능한 이유

Cross-platform compatibility is a design approach that allows software applications to function on multiple operating systems or environments with minimal modifications. Embarcadero’s Delphi, paired with the FireMonkey framework, is a prime example of this. At its core, Delphi is a versatile programming language, and FireMonkey (often abbreviated as FMX) is a cross-platform GUI toolkit designed for this very purpose. Together, they provide a robust foundation for developing applications that can effortlessly span multiple platforms.

크로스 플랫폼 호환성이란, 소프트웨어 애플리케이션을 최소한만 수정해 여러 운영 체제 또는 환경에서 작동할 수 있도록 해주는 설계 방식을 의미한다. 파이어몽키 프레임워크와 결합된 엠바카데로의 델파이는 바로 이 분야의 대표적인 예이다. 델파이는 본질적으로 다목적 프로그래밍 언어로, 파이어몽키(일반적으로 FMX로 부름)는 이를 위해 설계된 크로스 플랫폼 GUI 툴킷이다. 이 둘을 함께 사용하면, 여러 플랫폼을 지원하는 애플리케이션을 손쉽게 개발할 수 있는 강력한 기반을 얻을 수 있다.

The Stable Diffusion Desktop client, built upon this combination, has been primarily optimized for Windows. However, its inherent design allows for easy adaptability across a variety of platforms, including macOS and Linux. Moreover, with some tweaks, it can even be ported to mobile ecosystems like Android and iOS. This broad-spectrum compatibility is achieved through an abstraction layer provided by the FireMonkey framework, which translates general code into platform-specific executions. Thus, developers can write their code once and deploy it across multiple platforms, saving both time and resources.

크로스 플랫폼 호환이 가능한 스테이블 디퓨전 데스크탑 클라이언트는 윈도우에 최적화되어있다. 하지만 그 설계 방식 덕분에 macOS, 리눅스 등 다양한 플랫폼에서도 쉽게 사용할 수 있다. 또한 일부 수정만으로도 안드로이드와 iOS 등 모바일 생태계에도 적용할 수 있다. 이렇게 광범위한 호환성은 파이어몽키 프레임워크에서 제공하는 추상화 계층을 통해 가능하다. 개발자는 코드를 한 번만 작성해 여러 플랫폼에 배포할 수 있으므로, 시간과 리소스를 모두 절약할 수 있다.

 

델파이 개발자들에게는 어떤 이점이 있을까?

Delphi, as a development platform, has been serving developers for decades, offering tools that streamline coding processes. With the evolution of the FireMonkey (FMX) framework, Delphi has taken a leap forward in terms of user interface development. For seasoned Delphi developers, the direct ability to copy an FMX TImage from the client into the Delphi Integrated Development Environment (IDE) offers a range of benefits:

델파이는 개발 플랫폼으로서, 수십 년 간 개발자들에게 코딩 프로세스를 간소화하는 기술과 서비스를 제공해왔다. 파이어몽키(FMX) 프레임워크의 진화와 더불어 델파이는 사용자 인터페이스 개발에 있어 큰 발전을 이루었다. 숙련된 델파이 개발자라면, 클라이언트에서 델파이 통합 개발 환경(IDE)으로 FMX TImage를 바로 카피할 수 있는 등의 다양한 기능적 이점을 활용할 수 있다. 이 외에도 얻을 수 있는 이점은 다음과 같다:

  • 효율성: 직접 전송이 가능해 개발자들이 번거롭게 하는 여러 작업들, 예를 들면 수동으로 이미지 내보내기, 저장, 가져오기 등의 과정을 생략할 수 있다. 단순히 프로세스가 줄어드는 수준이 아니라 오류 가능성까지 줄여준다.
  • 통합 워크플로우: 클라이언트와 델파이 IDE 간에 컴포넌트를 원활하게 움직일 수 있는 기능을 제공해 더 일관되고 통합된 개발 프로세스를 보장할 수 있다. 이러한 연속성은 프로젝트 전반에서 일관성과 표준을 유지하는 데 도움이 된다.
  • 신속한 프로토타이핑: 사용자 인터베이스를 디자인하거나 조정하는 개발자들에게 신속한 프로토타이핑을 할 수 있도록 해준다. 변경 사항을 빠르게 시각화하고 테스트해 반복되는 디자인 프로세스의 속도를 높일 수 있다.
  • 시간 절약: 모든 간소화된 프로세스에서든, 가장 가시적인 이점은 시간이다. 기존 작업 흐름에서 몇 분씩 걸리던 작업을 이제 몇 초 만에 완료할 수 있어, 개발자들은 보다 복잡한 작업에 집중할 수 있다.

In essence, this integration between the client and the Delphi IDE represents a significant quality of life improvement for developers, simplifying and enhancing their everyday tasks.

궁극적으로, 클라이언트와 델파이 IDE의 통합은 개발자의 일상적인 작업을 간소화하고 개선해 개발자 삶의 질을 크게 향상시킨다.

 

다른 데스크탑 클라이언트보다 뛰어난 점은?

It has an integration with Replicate.com via REST to not only facilitates direct interfacing with online resources but also allows for a richer user experience due to the expanded functionality. By connecting with external platforms, users can access a plethora of tools and features without having access to the necessary GPU on the client. Additionally, it utilizes Skia4Delphi, an embedded component of the client, offers users a significant advantage when it comes to rendering. Recognized for its high-speed performance, Skia4Delphi ensures that images are displayed quickly.

REST로 Replicate.com과 통합하면서 온라인 리소스와 직접 연결할 수 있을 뿐 아니라, 기능이 더욱 확장되어 사용자 경험을 더 풍부하게 만들 수 있게 되었다. 외부 플랫폼과의 연결로 사용자는 클라이언트에서 필요한 GPU에 액세스하지 않고도 다양한 도구와 기능에 접근할 수 있다. 또한 클라이언트에 내장되어 있는 컴포넌트인 Skia4Delphi를 사용해 렌더링 측면에서 사용자들에게 상당한 이점을 제공한다. 빠른 성능으로 인정받은 Skia4Delphi는 이미지가 빠르게 표시되도록 보장한다.

Beyond these features, the client’s open-source nature elevates its stature. It ensures transparency, fosters community contributions, allows for unparalleled customizability, and reduces cost barriers. You can adapt the client or code for use within your own projects.

이러한 기능 외에도, 클라이언트의 오픈 소스라는 특성은 그 가치를 더욱 높여준다. 투명성이 보장되고, 커뮤니티가 적극 참여할 수 있도록 해주며 사용자가 직접 커스터마이징 할 수 있고 비용 장벽이 낮다는 점 또한 특징적이다. 클라이언트나 코드를 자체 프로젝트에서 사용할 수 있도록 조정이 가능하다. 

 

스테이블 디퓨전을 시작할 준비가 되었는가?

In an era where AI and creativity often intersect, the Stable Diffusion Desktop Client stands as a tool showing what’s possible for incorporating Stable Diffusion into your own projects. Whether you’re a developer looking for the next big tool to integrate into your workflow or an artist eager to explore new horizons, this open source project can get you started with generative AI.

AI와 창의성이 함께 활용되는 시대에 스테이블 디퓨전 데스크탑 클라이언트는 프로젝트에 스테이블 디퓨전을 적용할 수 있는 가능성을 보여주는 도구로 자리매김을 하고 있다. 업무에 차세대 대형 도구를 통합할 계획이 있는 개발자 또는 새로운 지평을 개척하고 싶은 아티스트라면, 이 오픈 소스 프로젝트로 생성형 AI를 시작할 수 있다.

As they say, seeing is believing. Dive into the world of Stable Diffusion and unleash your creative prowess!

백문이 불여일견이라는 말이 있다. 지금 스테이블 디퓨전의 세계로 뛰어들어 창의력을 마음껏 발휘해보자!

깃허브(GitHub)에서 전체 소스 코드를 확인하고 스테이블 디퓨전 데스크탑 클라이언트 릴리스 경로에서 바이너리를 다운로드 받을 수 있다.

 

GitHub - FMXExpress/Stable-Diffusion-Desktop-Client: Stable Diffusion Desktop client for Windows, macOS, and Linux built in Emba

Stable Diffusion Desktop client for Windows, macOS, and Linux built in Embarcadero Delphi. - GitHub - FMXExpress/Stable-Diffusion-Desktop-Client: Stable Diffusion Desktop client for Windows, macOS,...

github.com

[추가 자료]

관련 내용은 AI 엔진을 델파이로 직접 구현한 것은 아니고 AI 서비스를 제공하는 사이트에 Open API 로 연결하여 결과물을 서버에서 다운로드 받는 방식 입니다.

참고로 깃허브에 올라와 있는 샘플 프로젝트를 실행 하기 위해서는 사용하고자 하는 AI 모델의 해당 사이트에서 회원 가입후 키를 발급 받아야 합니다.

무료로 테스트 해 볼 수 있는 곳을 좀 찾아 봤는데 아직 찾지는 못했습니다.

하지만 샘플 프로젝트에 나열된 AI 모델 사이트가 50여개가 넘는데 해당 사이트에서 제공하는 Open API 의 접근 방법을 모두 구현해 놓았으므로 Open API 를 통한 AI 접근방법을 멀티플랫폼으로 구현 하고자 할때 매우 유용 할것 입니다.

 

 

728x90