crews

crews

保持学习和对新事物的热情~ Magic

"The realization of an idea: AI Sketching"

Background#

Around April, I delved into understanding AI "new things" like GPT and Midjourney, and then decided to get involved and truly use and experience them. The results of using Midjourney (hereinafter referred to as MJ) to create images were truly stunning, but there were actually quite a few issues during the usage process.

  1. MJ requires a VPN, and using it on Discord has certain requirements.
  2. The prompt command needs to be learned, and if you directly input Chinese, the recognition rate is not high, and it's easy to create images with significant deviations.
  3. I haven't accumulated enough professional vocabulary for prompts, and lack "awareness" and knowledge of how to use them.

This series of issues resulted in a less-than-ideal overall experience, so I thought about whether I could create an intermediate layer to handle this. I searched on GitHub and found that someone had already created an unofficial MJ interface: simulating a Discord account with a token to send messages, and having a bot listen to the messages. There are many ways to implement this, including Python, JavaScript, Go, and Java. I was able to find the language I wanted. Seeing that there was already a foundation for this, I started trying to create my own "tool site".

Getting Started#

Prototype#

As a programmer, when I decide to do something, I just do it. I quickly generated the code for a front-end project using Vite + React as the scaffolding, and as for the back-end, I used the most familiar and simplest Express. I got it up and running first.

I typed away at the code (I often write until late at night, but I don't recommend readers to do the same, as health is the most important thing), and then I completed an initial version before the May Day holiday. It was already functional.

image-20230516001048090

Technology stack used:

  • React + antd + vite for the front-end workflow
  • Express + Sqlite for the back-end server
  • GO for the open-source MJ wrapper
  • Alibaba Cloud Light Cloud (Singapore)

During the May Day holiday, I had personal matters to attend to and fell ill, which caused the website to stagnate and development to be put on hold.

image-20230516002225083

MVP Version#

The world is constantly changing, with new things emerging every day. I found myself deeply anxious and doubting the value and significance of what I was doing. My girlfriend told me that before I started doing these things, I had already told myself that I didn't expect to gain anything from them. I was doing it for the sake of interest and hobbies, and to learn new technologies, which was already great. If I felt tired, I didn't have to continue doing it. After hearing this, I suddenly understood. Indeed, I should return to my original intention. I did these things because I found joy in doing them, not because I expected to gain something from them. So I made a plan for an MVP version, aiming to add an account system, improve UI support for mobile devices, and make the tool more user-friendly by supporting prompts.

I set a deadline to complete a preliminary MVP version by May 14th.

During the holiday, I also acquired a lot of knowledge and explored many frameworks. In the end, I decided to use Next.js to build this website.

The technology stack changed to:

  • Next.js + Typescript
  • tailwindcss + daisyui
  • Prisma + Sqilte
  • Go

The development process became much smoother. With the help of ChatGPT, I quickly converted the previously written Express APIs and utility functions into TypeScript code.

I really spent every evening after work writing code until late at night, and I spent two days over the weekend to refactor this MVP version. It felt like I wrote a lot of code, and the speed was really much faster.

Writing code in TypeScript is really enjoyable. When defining interfaces, it can help detect many problems while writing code. Strong type checking is a must for writing interfaces.

Here are some examples of the actual effects of the website:

home

tool

history

If you want to experience MJ's drawing capabilities, you can message me privately, and I will reply with the website URL. Since it's part of my personal toy series and is still in the BETA version, it's open to a wide audience.

Interlude#

After deploying the code last night, I went to bed and everything was fine (because no one was using it).

When I woke up in the morning, a few friends were using it. They ran a few images and it was fine, but suddenly it started to become extremely slow. I quickly got up and checked my server, but I couldn't even connect via SSH. I checked the CPU and it seemed normal, but it took a long time to get into SSH, and I found that the memory was overloaded. I had only purchased the cheapest Light Cloud with 1GB of memory, and it was overwhelmed. I immediately upgraded to a higher-tier server in the background, and then everything returned to normal.

This made me think about the differences between work development, work deployment, and personal development deployment. In work, I basically don't have to worry about server issues, and I don't have to consider performance issues with the server code because the company has my back. For personal development services, I realized that every bit of memory and CPU is money, and must be taken into consideration. In the future, I may consider using Go to develop the server, as it definitely offers a high cost-performance ratio. However, JavaScript is currently the main language, and it allows for a unified language for both front-end and back-end, so I'm still hesitating.

Conclusion#

In the past, I had many ideas, but I always had a good start and never continued to execute them. Now, I still have just as many ideas, but the difference is that I want to follow through and execute them to the end. This time is also a new attempt for me. I wrote the entire website from front to back, including the UI, relying solely on my coding abilities, and it feels very fulfilling. I feel that my coding skills have improved a lot. My English reading ability has also improved because I've been constantly referring to documentation and have become too lazy to use translation plugins, so I just read the original text.

"Getting involved" and "persevering to the end" truly allow for growth and insights in completing a task. Regardless of the final outcome, the process itself is the greatest reward.

The speed of iterative updates for this small website may slow down in the future. Interested students can follow and communicate with me via WeChat.

Thank you all for reading!

扫码_搜索联合传播样式 - 标准色版

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.