Mitsua commited on
Commit
4008379
·
verified ·
1 Parent(s): d3f86f7

Upload 5 files

Browse files
Files changed (5) hide show
  1. LikesHFFooter.png +0 -0
  2. MitsuaLikesLogoWhite.png +0 -0
  3. app.js +61 -0
  4. app.py +431 -0
  5. requirements.txt +7 -0
LikesHFFooter.png ADDED
MitsuaLikesLogoWhite.png ADDED
app.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function changeLangLabel() {
2
+ var userLang = navigator.language || navigator.userLanguage;
3
+
4
+ var ja = {
5
+ 'title': 'Mitsua Likes Demo',
6
+ 'subtitle': 'ミツアちゃんと日本語・英語で楽しく画像生成🔖 ※利用規約を守ってご利用ください',
7
+ 'textbox_placeholder': 'ここにプロンプトを入力',
8
+ 'descriptions': [
9
+ '本モデルは、画像生成AIを構成する全てのモジュール(CLIP, VAE, UNet)をオプトインの許諾済みデータ、オープンライセンスのデータ、パブリックドメインのデータのみでゼロから学習しました。',
10
+ '学習データに他の画像生成AIのAI生成画像は含まれません。学習データに他のVLM/LLMなどのAI生成テキストは含まれません。',
11
+ '本モデルは学習データの前処理の過程でも、不適切なデータの除外(=AI生成データのフィルタリング等)という目的を除き、既存のあらゆる種類の学習済みモデルを使用していません。',
12
+ '学習データや学習方法の詳細は<a href="https://huggingface.co/Mitsua/mitsua-likes">モデルカード</a>をご参照ください。',
13
+ '入力されたプロンプトがサーバーに保存されたり、AI学習に使用されたりすることはありません。',
14
+ '免責事項:当社はMitsua Likes BY-NCライセンスに基づき、本モデルの使用によって生じた直接的または間接的な損失に対して、一切の責任を負いません。',
15
+ '(c) 2024 ELAN MITSUA Project / Abstract Engine',
16
+ ],
17
+ 'btn_label': '🎨生成してもらう',
18
+ };
19
+ var en = {
20
+ 'title': 'Mitsua Likes Demo',
21
+ 'subtitle': 'Let\'s enjoy English / Japanese image generation with Mitsua-chan🔖 *Please abide by the terms',
22
+ 'textbox_placeholder': 'Enter prompt here',
23
+ 'descriptions': [
24
+ 'This model, an entire architecture of text-to-image generative model (CLIP, VAE, UNet), is trained solely on opt-in licensed data, openly licensed data and public domain data.',
25
+ 'No AI synthetic data (images and texts) are included in the training dataset.',
26
+ 'No pre-trained models in any kind are used for preprocessing data, except for excluding inappropriate data like AI generated images.',
27
+ 'Please refer to <a href="https://huggingface.co/Mitsua/mitsua-likes">the model card</a> for more information on training data and training details.',
28
+ 'No input text is stored on the server or used for AI training.',
29
+ 'Disclaimer : Under Mitsua Likes BY-NC License, ELAN MITSUA Project / Abstract Engine is not responsible for any direct or indirect loss caused by the use of the model.',
30
+ '(c) 2024 ELAN MITSUA Project / Abstract Engine',
31
+ ],
32
+ 'btn_label': '🎨Request',
33
+ };
34
+
35
+ var titleElement = document.querySelector("#title h1");
36
+ var subtitleElement = document.querySelector("#title h3");
37
+ var placeholderElement = document.querySelector("#text_input textarea");
38
+ var descriptionElements = document.querySelectorAll("#description li");
39
+ var startButtonElement = document.querySelector("#start_btn");
40
+ // var generalThesholdElement = document.querySelector("#general_threshold span");
41
+ // var characterThesholdElement = document.querySelector("#character_threshold span");
42
+
43
+ var label = userLang.startsWith('ja') ? ja : en;
44
+ titleElement.textContent = label.title;
45
+ subtitleElement.textContent = label.subtitle;
46
+ descriptionElements.forEach((elem, index) => {
47
+ elem.innerHTML = label.descriptions[index];
48
+ });
49
+ startButtonElement.textContent = label.btn_label;
50
+ placeholderElement.placeholder = label.textbox_placeholder;
51
+ placeholderElement.focus()
52
+ // generalThesholdElement.textContent = label.general_threshold_label;
53
+ // characterThesholdElement.textContent = label.character_threshold_label;
54
+
55
+ // Set the language in the hidden lang_input textbox
56
+ let langInputElement = document.querySelector("#lang_input textarea");
57
+ langInputElement.value = userLang;
58
+ var myEvent = new Event("input");
59
+ Object.defineProperty(myEvent, "target", {value: langInputElement});
60
+ langInputElement.dispatchEvent(myEvent);
61
+ }
app.py ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import spaces
2
+ import gradio as gr
3
+ import os
4
+ from transformers import pipeline
5
+ from collections import defaultdict
6
+ import torch
7
+
8
+ from typing import Iterable
9
+ from gradio.themes.base import Base
10
+ from gradio.themes.utils import colors, fonts, sizes
11
+ from PIL import Image
12
+ import datetime
13
+ from diffusers import DiffusionPipeline
14
+ import random
15
+ import numpy as np
16
+ from huggingface_hub import login
17
+
18
+ login(token=os.environ.get("TOKEN"))
19
+
20
+ device = "cuda" if torch.cuda.is_available() else "cpu"
21
+ dtype = torch.float16
22
+
23
+ print('script starting up...')
24
+
25
+ # never do this"
26
+ print('loading model...')
27
+ auth_token = True
28
+ pipe = DiffusionPipeline.from_pretrained("Mitsua/mitsua-likes", token=auth_token, trust_remote_code=True).to(device, dtype=dtype)
29
+ bad_words = os.environ.get("BAD_WORDS").split(",")
30
+
31
+ PUBLIC_CHARACTER_NAMES_JA = set([
32
+ '絵藍ミツア',
33
+ 'つくよみちゃん',
34
+ 'ずんだもん',
35
+ '紡ネン',
36
+ '東北ずん子',
37
+ '東北イタコ',
38
+ '東北きりたん',
39
+ '四国めたん',
40
+ '中国うさぎ',
41
+ '原型ずんだもん',
42
+ '九州そら',
43
+ '大江戸ちゃんこ',
44
+ 'フィーちゃん',
45
+ '19歳つくよみちゃん'
46
+ ])
47
+
48
+ PUBLIC_CHARACTER_NAMES_EN = set([
49
+ 'elanmitsua',
50
+ 'tsukuyomichan',
51
+ 'zundamon',
52
+ 'tsumugi nen',
53
+ 'touhoku zunko',
54
+ 'touhoku itako',
55
+ 'touhoku kiritan',
56
+ 'shikoku metan',
57
+ 'chugoku usagi',
58
+ 'zundamon_original',
59
+ 'kyushu_sora',
60
+ 'kansai_shinobi',
61
+ 'ccd-0500',
62
+ '19sai_tsukuyomichan'
63
+ ])
64
+
65
+ PUBLIC_CHARACTER_LINKS = {
66
+ '絵藍ミツア': "https://elanmitsua.com/",
67
+ '原型ずんだもん': "https://zunko.jp/",
68
+ '九州そら': "https://zunko.jp/",
69
+ '大江戸ちゃんこ': "https://zunko.jp/",
70
+ 'フィーちゃん': "https://u-stella.co.jp/gallery/ccd-0500/",
71
+ '19歳つくよみちゃん': "https://tyc.rei-yumesaki.net/",
72
+ 'つくよみちゃん': "https://tyc.rei-yumesaki.net/",
73
+ 'ずんだもん': "https://zunko.jp/",
74
+ '紡ネン': "https://tsumuginen.com/",
75
+ '東北ずん子': "https://zunko.jp/",
76
+ '東北イタコ': "https://zunko.jp/",
77
+ '東北きりたん': "https://zunko.jp/",
78
+ '四国めたん': "https://zunko.jp/",
79
+ '中国うさぎ': "https://zunko.jp/"
80
+ }
81
+
82
+ license_str_ja_orig = """
83
+ # 画像ライセンス : [Mitsua Likes 表示-非営利](https://elanmitsua.notion.site/Mitsua-Likes-15baa85a9b278005bba5f30866a35f48)
84
+ ## クレジット表示必須
85
+ - 生成物にMitsua Likesのクレジットを合理的な方法で表示しなければなりません。クレジットは以下のいずれかを指します。
86
+ - Generated by Mitsua Likes
87
+ - 画像生成:Mitsua Likes
88
+ ## 非商用限定
89
+ - 生成物の商用利用不可 (自身の創造的目的のための個人商用利用を除く)
90
+ - 企業商用利用については[お問い合わせ](https://abstractengine.ltd/#contact)までお問い合わせください
91
+ ## 禁止事項(抜粋)
92
+ - 差別・誹謗中傷・侮辱・名誉棄損
93
+ - 第三者の知的財産権・プライバシーの侵害
94
+ - 虚偽の情報の流布
95
+ - 営利目的で素材として販売する行為
96
+ - 機械学習を目的とした、データセット作成行為
97
+ - その他、法令、公序良俗に違反する/おそれがある反社会的行為
98
+ """
99
+
100
+ license_str_en_orig = """
101
+ # Image License : [Mitsua Likes BY-NC](https://elanmitsua.notion.site/Mitsua-Likes-Attribution-NonCommercial-License-15baa85a9b278038be5dc7f47a9c26cc)
102
+ ## Attribution required
103
+ - You must give appropriate credit of "Mitsua Likes" for sharing generated result. “Credits for Mitsua Likes” means displaying one of the following statements:
104
+ - Generated by Mitsua Likes
105
+ - 画像生成:Mitsua Likes
106
+ ## Non-Commercial use only
107
+ - Non-Commercial use only, except for individual commercial use of creative purpose.
108
+ - For corporation commercial use, please contact at [this contact form](https://abstractengine.ltd/en/#contact)
109
+ ## Prohibited Acts
110
+ - Acts that discriminate against, defame, or insult MITSUA Project or third parties, damaging their honor or credibility.
111
+ - Acts that infringe or may infringe on the intellectual property rights or privacy of MITSUA Project or third parties.
112
+ - Disseminating information or content that unjustly harms the interests of MITSUA Project or third parties.
113
+ - Disseminating false information or content.
114
+ - Distributing or selling the Mitsua Likes Generated Data, etc., as materials for commercial purposes.
115
+ - Other antisocial acts that violate or may violate laws, regulations, or public order and morals.
116
+ - Creating a dataset composed primarily of Generated Data for the purpose of machine learning.
117
+ """
118
+
119
+ @spaces.GPU
120
+ def infer(
121
+ prompt,
122
+ style,
123
+ lang='ja',
124
+ negative_prompt="elan doodle",
125
+ seed=42,
126
+ randomize_seed=True,
127
+ ar="1:1",
128
+ # width=672,
129
+ # height=896,
130
+ guidance_scale=5.0,
131
+ num_inference_steps=40,
132
+ progress=gr.Progress(track_tqdm=True),
133
+ ):
134
+ now = datetime.datetime.now()
135
+ print("button clickeds : ", now, prompt, style, lang)
136
+ style_to_prompt = {
137
+ "sensei art / 先生アート" : "先生アートsensei artイラスト",
138
+ "digital illustration / デジタルイラスト" : "デジタルイラスト、digital illustration",
139
+ "analog illustration / アナログイラスト" : "アナログ風、illustration",
140
+ "3d cg" : "3d cg",
141
+ "artworks / 芸術作品" : "芸術作品artworks, paintings",
142
+ # "none": "",
143
+ }
144
+ style2negative_prompt = {
145
+ "sensei art / 先生アート" : "photo",
146
+ "digital illustration / デジタルイラスト" : "photo",
147
+ "analog illustration / アナログイラスト" : "vrm, cg, photo",
148
+ "3d cg" : "photo",
149
+ "artworks / 芸術作品" : "vrm, cg, photo",
150
+ # "none" : "",
151
+ }
152
+
153
+ if any([a in prompt for a in bad_words]):
154
+ return None, "## <span style='color:orangered'>ERROR: Invalid prompt / 不適切なプロンプト </span>", None, seed
155
+
156
+ if randomize_seed:
157
+ seed = random.randint(0, np.iinfo(np.int32).max)
158
+
159
+ yield None, None, None, seed
160
+
161
+ generator = torch.Generator(device=device).manual_seed(seed)
162
+ if style_to_prompt[style] != "":
163
+ prompt = style_to_prompt[style] + ", " + prompt
164
+ # prompt = prompt + " " + style_to_prompt[style]
165
+ negative_prompt = negative_prompt + ", " + style2negative_prompt[style]
166
+ print("prompt : ", prompt)
167
+ print("ne_prompt : ", negative_prompt)
168
+
169
+ width, height = 768, 768
170
+ if ar == '16:9':
171
+ width, height = 1024, 576
172
+ elif ar == '4:3':
173
+ width, height = 896, 672
174
+ elif ar == '1:1':
175
+ width, height = 768, 768
176
+ elif ar == '3:4':
177
+ width, height = 672, 896
178
+ elif ar == '9:16':
179
+ width, height = 576, 1024
180
+
181
+ ret = pipe(
182
+ prompt=prompt,
183
+ negative_prompt=negative_prompt,
184
+ guidance_scale=guidance_scale,
185
+ guidance_rescale=0.7,
186
+ num_inference_steps=num_inference_steps,
187
+ width=width,
188
+ height=height,
189
+ generator=generator,
190
+ )
191
+ image = ret.images[0]
192
+ detected_public_fictional_characters = ret.detected_public_fictional_characters[0]
193
+ detected_public_fictional_characters_info=ret.detected_public_fictional_characters_info[0]
194
+
195
+
196
+ license_str_ja = license_str_ja_orig
197
+ license_str_en = license_str_en_orig
198
+
199
+ def get_link_str(k):
200
+ return f"[{k}]({PUBLIC_CHARACTER_LINKS[k]})" if k in PUBLIC_CHARACTER_LINKS else k
201
+
202
+ if len(detected_public_fictional_characters) > 0:
203
+ license_str_ja += f"## <span style='color:orangered'>類似による追加の制約: {','.join(detected_public_fictional_characters)}</span>\n"
204
+ license_str_en += f"## <span style='color:orangered'>Similarity Restriction: {','.join(detected_public_fictional_characters)}</span>\n"
205
+ for k,v in detected_public_fictional_characters_info.items():
206
+ if k in detected_public_fictional_characters:
207
+ license_str_ja += f"- 「{get_link_str(k)}」の利用規約または二次創作ガイドラインに従う必要があります\n"
208
+ license_str_en += f"- Abide by the terms or the derivative guideline of \"{get_link_str(k)}\" required.\n"
209
+
210
+ if any([a in prompt for a in PUBLIC_CHARACTER_NAMES_JA if a not in detected_public_fictional_characters]):
211
+ license_str_ja += f"## <span style='color:orangered'>プロンプトによる追加の制約: {','.join([a for a in PUBLIC_CHARACTER_NAMES_JA if a in prompt and a not in detected_public_fictional_characters])}</span>\n"
212
+ license_str_en += f"## <span style='color:orangered'>Prompt Restriction: {','.join([a for a in PUBLIC_CHARACTER_NAMES_JA if a in prompt and a not in detected_public_fictional_characters])}</span>\n"
213
+ for k in PUBLIC_CHARACTER_NAMES_JA:
214
+ if k in prompt and k not in detected_public_fictional_characters:
215
+ license_str_ja += f"- 「{get_link_str(k)}」の利用規約または二次創作ガイドラインに従う必要があります\n"
216
+ license_str_en += f"- Abide by the terms or the derivative guideline of \"{get_link_str(k)}\" required.\n"
217
+
218
+ if any([a in prompt for a in PUBLIC_CHARACTER_NAMES_EN if a not in detected_public_fictional_characters]):
219
+ license_str_ja += f"## <span style='color:orangered'>プロンプトによる追加の制約: {','.join([a for a in PUBLIC_CHARACTER_NAMES_EN if a in prompt and a not in detected_public_fictional_characters])}</span>\n"
220
+ license_str_en += f"## <span style='color:orangered'>Prompt Restriction: {','.join([a for a in PUBLIC_CHARACTER_NAMES_EN if a in prompt and a not in detected_public_fictional_characters])}</span>\n"
221
+ for k in PUBLIC_CHARACTER_NAMES_EN:
222
+ if k in prompt and k not in detected_public_fictional_characters:
223
+ license_str_ja += f"- 「{get_link_str(k)}」の利用規約または二次創作ガイドラインに従う必要があります\n"
224
+ license_str_en += f"- Abide by the terms or the derivative guideline of \"{get_link_str(k)}\" required.\n"
225
+
226
+ names = [c for c in detected_public_fictional_characters_info if c not in detected_public_fictional_characters and not c in prompt]
227
+ if len(names) > 0:
228
+ license_str_ja += f"## <span style='color:darkorange'>類似可能性の通知: {','.join(names)}</span>\n"
229
+ license_str_en += f"## <span style='color:darkorange'>Possible Similarity Notice: {','.join(names)}</span>\n"
230
+ for k in names:
231
+ license_str_ja += f"- 「{get_link_str(k)}」に類似している可能性があります。公式キャラクターデザインをご確認の上、「{get_link_str(k)}」の利用規約または二次創作ガイドラインに従うかを検討してください\n"
232
+ license_str_en += f"- Image might look like \"{get_link_str(k)}\". Please confirm their character design and consider to abide by their derivative guideline.\n"
233
+
234
+ license_str = license_str_ja if lang.startswith('ja') else license_str_en
235
+
236
+ likes_logo_img = Image.open("LikesHFFooter.png")
237
+ likes_logo_top_img = Image.open("MitsuaLikesLogoWhite.png")
238
+ image_w_logo = Image.new("RGB", (image.width, image.height + likes_logo_img.height), (255, 255, 255))
239
+ image_w_logo.paste(image)
240
+ image_w_logo.paste(likes_logo_top_img, (image.width - likes_logo_top_img.width,0), likes_logo_top_img)
241
+ image_w_logo.paste(likes_logo_img, (0, image.height))
242
+ yield image_w_logo, license_str, detected_public_fictional_characters_info, seed
243
+
244
+
245
+ # Seafoam theme based on
246
+ # https://huggingface.co/spaces/gradio/seafoam
247
+ # https://github.com/gradio-app/gradio
248
+ class ModifiedSeafoam(Base):
249
+ def __init__(
250
+ self,
251
+ *,
252
+ primary_hue: colors.Color | str = colors.cyan,
253
+ secondary_hue: colors.Color | str = colors.sky,
254
+ neutral_hue: colors.Color | str = colors.sky,
255
+ spacing_size: sizes.Size | str = sizes.spacing_sm,
256
+ radius_size: sizes.Size | str = sizes.radius_lg,
257
+ text_size: sizes.Size | str = sizes.text_lg,
258
+ font: fonts.Font
259
+ | str
260
+ | Iterable[fonts.Font | str] = (
261
+ fonts.GoogleFont("Quicksand"),
262
+ "ui-sans-serif",
263
+ "sans-serif",
264
+ ),
265
+ font_mono: fonts.Font
266
+ | str
267
+ | Iterable[fonts.Font | str] = (
268
+ fonts.GoogleFont("IBM Plex Mono"),
269
+ "ui-monospace",
270
+ "monospace",
271
+ ),
272
+ ):
273
+ super().__init__(
274
+ primary_hue=primary_hue,
275
+ secondary_hue=secondary_hue,
276
+ neutral_hue=neutral_hue,
277
+ spacing_size=spacing_size,
278
+ radius_size=radius_size,
279
+ text_size=text_size,
280
+ font=font,
281
+ font_mono=font_mono,
282
+ )
283
+ super().set(
284
+ body_background_fill="linear-gradient(0deg, *primary_200, *primary_50)",
285
+ body_background_fill_dark="linear-gradient(0deg, *secondary_900, *secondary_950)",
286
+ button_primary_background_fill="linear-gradient(0deg, *primary_400, *secondary_400)",
287
+ button_primary_background_fill_hover="linear-gradient(0deg, *primary_400, *secondary_200)",
288
+ button_primary_background_fill_dark="linear-gradient(0deg, *primary_800, *secondary_800)",
289
+ button_primary_background_fill_hover_dark="linear-gradient(0deg, *primary_800, *secondary_600)",
290
+ button_primary_text_color="*primary_900",
291
+ button_primary_text_color_hover="*primary_800",
292
+ slider_color="*secondary_300",
293
+ slider_color_dark="*primary_600",
294
+ block_title_text_weight="600",
295
+ block_border_width="3px",
296
+ block_shadow="*shadow_drop_lg",
297
+ # button_shadow="*shadow_drop_lg",
298
+ # button_large_padding="32px",
299
+ )
300
+
301
+
302
+
303
+
304
+ if __name__ == "__main__":
305
+ import argparse
306
+ parser = argparse.ArgumentParser(description='Mitsua Likes Image Generator')
307
+ parser.add_argument('--share', action="store_true")
308
+ args = parser.parse_args()
309
+ ui_text = {
310
+ 'title': 'Mitsua Likes Demo',
311
+ 'description': "Let's enjoy image generation!",
312
+ 'dropdown_label': 'Translation Direction',
313
+ 'textbox_placeholder': 'Enter text here',
314
+ 'checkbox_label': 'Translate by sentence'
315
+ }
316
+ with open('app.js', mode='r', encoding='utf-8') as jsfp:
317
+ js = jsfp.read()
318
+ theme = ModifiedSeafoam()
319
+ css="""
320
+ #output_image {
321
+ display: block !important;
322
+ margin-left: auto !important;
323
+ margin-right: auto !important;
324
+ max-width: 640px !important;
325
+ max-height: 640px !important;
326
+ overflow: hidden !important;
327
+ position: relative !important;
328
+ }
329
+ #output_image img {
330
+ object-fit: contain !important;
331
+ max-width: 100% !important;
332
+ max-height: 635px !important;
333
+ width: auto !important;
334
+ height: auto !important;
335
+ }
336
+ footer {
337
+ display:none !important
338
+ }
339
+ """
340
+ with gr.Blocks(title=ui_text['title'], js=js, css=css, theme=theme) as demo:
341
+ # with gr.Blocks(title=ui_text['title'], theme=theme) as demo:
342
+ gr.Markdown("""
343
+ # Title
344
+ ### ミツアちゃんと楽しく画像生成🔖
345
+ Demo for [Mitsua Likes model](https://huggingface.co/Mitsua/mitsua-likes) licensed under [Mitsua Likes Attribution Non-Commercial License](https://elanmitsua.notion.site/Mitsua-Likes-Attribution-NonCommercial-License-15baa85a9b278038be5dc7f47a9c26cc)
346
+ """, elem_id='title')
347
+ li = """
348
+ - Description
349
+ - Notes
350
+ - Notes
351
+ - Notes
352
+ - Notes
353
+ - Disclaimer
354
+ - Copyright
355
+ """
356
+ # Hidden textbox to store the language
357
+ lang_input = gr.Textbox(value='', elem_id='lang_input', visible=False, interactive=False)
358
+ with gr.Row():
359
+ prompt = gr.Textbox(
360
+ label="Prompt",
361
+ lines=1, max_lines=3,
362
+ placeholder="Enter prompt here",
363
+ elem_id="text_input",
364
+ container=False,
365
+ min_width=500,
366
+ )
367
+ btn = gr.Button("Generate", elem_id='start_btn', variant="primary", size="lg", min_width=240, scale=0)
368
+ with gr.Accordion("Advanced Settings", open=False):
369
+ negative_prompt = gr.Textbox(
370
+ label="Negative Prompt",
371
+ lines=1, max_lines=3,
372
+ placeholder="Enter negative prompt here",
373
+ value="elan doodle, lowres",
374
+ elem_id="text_input",
375
+ # container=False,
376
+ )
377
+
378
+ with gr.Row():
379
+ with gr.Column(scale=1):
380
+ styles = gr.Dropdown(
381
+ ["sensei art / 先生アート", "digital illustration / デジタルイラスト", "analog illustration / アナログイラスト", "3d cg", "artworks / 芸術作品"],
382
+ value="digital illustration / デジタルイラスト",
383
+ label="Style",
384
+ )
385
+ with gr.Column(scale=1):
386
+ ar = gr.Dropdown(
387
+ ["16:9", "4:3", "1:1", "3:4", "9:16"],
388
+ value="3:4",
389
+ label="Aspect Ratio",
390
+ )
391
+
392
+ with gr.Column(scale=1):
393
+ seed = gr.Slider(
394
+ label="Seed",
395
+ minimum=0,
396
+ maximum=np.iinfo(np.int32).max,
397
+ step=1,
398
+ value=0,
399
+ )
400
+ randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
401
+
402
+ guidance_scale = gr.Slider(
403
+ label="Guidance Scale",
404
+ minimum=1,
405
+ maximum=10,
406
+ step=0.1,
407
+ value=5.0,
408
+ )
409
+
410
+ with gr.Row():
411
+ with gr.Column(scale=1):
412
+ result = gr.Image(label="Result", show_label=False, elem_id="output_image", min_width=500)
413
+ with gr.Column(scale=1):
414
+ license_md = gr.Markdown("", elem_id='license_str')
415
+ character_similarities = gr.Label(label="Character Similarity Measure")
416
+ gr.Markdown(li, elem_id='description')
417
+ gr.on(
418
+ triggers=[btn.click, prompt.submit],
419
+ fn = infer,
420
+ inputs = [prompt, styles, lang_input, negative_prompt, seed, randomize_seed, ar, guidance_scale],
421
+ outputs = [result, license_md, character_similarities, seed],
422
+ js="""
423
+ function(x, z, y, a, b, c, d, e){
424
+ var userLang = navigator.language || navigator.userLanguage;
425
+ let langInputElement = document.querySelector("#lang_input textarea");
426
+ return [x,z,userLang,a,b,c,d,e];
427
+ }
428
+ """,
429
+ )
430
+
431
+ demo.queue().launch(show_api=False, share=False)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ transformers==4.44.2
2
+ diffusers==0.31.0
3
+ gradio==5.9.0
4
+ # torch
5
+ sentencepiece==0.2.0
6
+ protobuf==5.28.3
7
+ huggingface-hub==0.26.5