• Stars
    star
    131
  • Rank 275,867 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 1 year ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Optimize the prompt using ChatGPT, then send it to Replicate to create an image.

text2image

replicate.com 提供了 Model as a Service 的服务,大大降低了普通人玩 Machine Leaning 的门槛,写了一个小工具,将文案送给 ChatGPT 生成可用于图片模型的 Prompt 后,交给 replicate 服务生成图片。—— Barret李靖

你可以将本项目直接部署到 Vercel,点击部署

启动和调试

安装依赖后,直接执行:

OPENAI_KEY=${YOUR_KEY} npm run dev
# or
yarn dev
# or
pnpm dev

然后浏览器打开 http://localhost:3000

参数设置

由于免费版的 Vercel 执行函数有时长限制,超过 10s 就直接掐断请求了,可以考虑将 api/text2image 的内容部署到 aircode.io 上,然后在网页添加 proxyUrl:

http://localhost:3000?proxyUrl=${YOUR_AIRCODE_PROJECT_URI}

Replicate 上有很多生成好的模型,配置后可以直接运行,在这个工具中,你可以通过配置 url 参数更换 mode:

http://localhost:3000?m=${MODEL_FROM_REPLICATE}

我已经在 aircode 上部署了一个副本:https://aircode.cool/nfyiwynauv,点击 copy 即可完成部署:

了解 Replicate

如果你只想了解 Replicate,可以直接执行这份代码:

cosnt main = async () => {
  const replicate = await import('node-replicate');
  # https://replicate.com/prompthero/openjourney
  const model = 'prompthero/openjourney:9936c2001faa2194a261c01381f90e65261879985476014a0a37a334593a05eb'
  const input = { prompt: "an astronaut riding on a horse" }
  await replicate.default.run(model, input);
}
await main();

License

MIT

More Repositories

1

performance-column

🚅 性能专栏(Performance Column)
1,202
star
2

online-markdown

A online markdown converter specially for Wechat Public formatting.
JavaScript
868
star
3

cloudflare-proxy

Cloudflare Worker 代理请求 ChatGPT API,支持 Stream 流式输出
JavaScript
695
star
4

autoconfig-mac-vimrc

autoconfig mac vimrc with bundle
Vim Script
514
star
5

blogChat

Chat room source code for Barret Lee's Personal Blog.
HTML
498
star
6

kindleBookMaker

Kindle Book Maker with KindleGen, Make Book from RSS/single URL/directory and so on.
JavaScript
393
star
7

algorithms

All algorithms writing with javascript in the book 'Algorithms Fourth Edition'.
JavaScript
331
star
8

snippets

Code Snippets
JavaScript
316
star
9

daily-algorithms

算法,每日练习
JavaScript
227
star
10

blog

Blog & Blog System
HTML
177
star
11

SuperMarker

An automatic marking tool better than mark man.
JavaScript
150
star
12

javascript-multiple-download

JavaScript多文件下载
JavaScript
95
star
13

lazyload

Lazyload images or lazy execute scripts. (图片脚本懒加载)
HTML
91
star
14

autocreate-ca

autocreate cetificate authority
Shell
63
star
15

babel-plugin-ast

使用 babel 进行 AST 分析和处理
JavaScript
45
star
16

myPromise

promise
JavaScript
42
star
17

proxyer

一键完成 VPS 裸机的代理程序安装(含证书)
Shell
41
star
18

translation-plan

翻译计划
36
star
19

Node-Daily-Practice

每天写个小程序。
30
star
20

alfred-workflow-paste-image-to-file

Paste image to file from clipboard to desktop
AppleScript
25
star
21

node-debug

Node Debug Demo
HTML
22
star
22

MiniQuery

MiniQuery,寥寥几行代码,实现一个简单的元素选择器,兼容低版本 IE。
JavaScript
19
star
23

h5crash

H5 容器 Crash 问题研究
HTML
17
star
24

performance

Javascript Performace Tester
JavaScript
14
star
25

ddns

将本机的外网 ip 推到 DNSPod
PHP
11
star
26

hexo-search-plugin-snippets

一些辅助 `hexo-generator-search` 插件的代码片段,博客右上角看效果 ---->
JavaScript
11
star
27

duoshuo-migrate-to-disqus

将多说评论迁移到disqus,nodejs程序
JavaScript
10
star
28

dive-into-node-stream

Dive Into Node Stream
JavaScript
9
star
29

debugging-in-vscode-tutorial

Demostration of Debugging in vscode.
HTML
8
star
30

xss-filter-bypass

xss-filter-bypass
JavaScript
8
star
31

Micro-Share

微分享
HTML
4
star
32

node-legacy-debug

Node Legacy Demo
JavaScript
3
star
33

git-rebase

Git Rebase Demo
HTML
2
star
34

weibo

weibo list
2
star
35

pocket

pocket list
2
star
36

parser-learning

编程语言实现模式
JavaScript
1
star
37

Rime-config

Rime Config
Shell
1
star
38

dht

dht
JavaScript
1
star
39

gitbook-plugin-tbobook

JavaScript
1
star
40

slides

小胡子哥的演讲
JavaScript
1
star
41

3d-demo

Collection of 3D Demo
1
star
42

base64-utf8-transfer

base64 for utf8 character
JavaScript
1
star
43

hexo-lazyload-image-enhance

a hexo plugin which is used to have all images support lazyload, with the help of this functionality, it will improve lots of the loading proformance.
JavaScript
1
star
44

ppt

1
star
45

skylarblog

blog for skylar
JavaScript
1
star