feat: added model selector
This commit is contained in:
parent
95f22c268b
commit
a264e91f1f
@ -109,6 +109,7 @@ def _gen_text(prompt, use_zukijourney=False):
|
||||
@app.route('/gen_image', methods=['GET'])
|
||||
def gen_image():
|
||||
prompt = request.args.get('prompt')
|
||||
model = request.args.get('model', 'playground-v2.5')
|
||||
|
||||
if not prompt:
|
||||
return "Error: No prompt provided", 400
|
||||
@ -119,7 +120,7 @@ def gen_image():
|
||||
try:
|
||||
client = get_client()
|
||||
response = client.images.generate(
|
||||
model="playground-v2.5",
|
||||
model=model,
|
||||
prompt=prompt,
|
||||
)
|
||||
image_url = response.data[0].url
|
||||
|
@ -1,9 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { ProgressRadial, getToastStore } from '@skeletonlabs/skeleton';
|
||||
import { ProgressRadial, getToastStore, RadioGroup, RadioItem } from '@skeletonlabs/skeleton';
|
||||
|
||||
let inputText = '';
|
||||
let imageUrl = '';
|
||||
|
||||
const models = [
|
||||
{
|
||||
name: "Runway v2.5",
|
||||
value: "runway-v2.5",
|
||||
},
|
||||
{
|
||||
name: "Dall-e 3",
|
||||
value: "dall-e-3",
|
||||
},
|
||||
{
|
||||
name: "Stable Diffusion 3",
|
||||
value: "stable-diffusion-3",
|
||||
},
|
||||
{
|
||||
name: "Pollinations",
|
||||
value: "pollinations"
|
||||
},
|
||||
{
|
||||
name: "RealVis XL 4",
|
||||
value: "realvisxl-v4",
|
||||
},
|
||||
{
|
||||
name: "CyberRealistic",
|
||||
value: "cyberrealistic-v3.3",
|
||||
}
|
||||
]
|
||||
|
||||
let currentModel = models[0].value;
|
||||
|
||||
let generateFutureAbortController = new AbortController();
|
||||
let generateFutureAbortSignal = generateFutureAbortController.signal;
|
||||
|
||||
@ -33,7 +62,8 @@
|
||||
isGenerating = true;
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/forward/gen_image?prompt=${encodeURIComponent(inputText)}`,
|
||||
`/api/forward/gen_image?prompt=${encodeURIComponent(inputText)}&model=${encodeURIComponent(currentModel)}`,
|
||||
|
||||
{ signal }
|
||||
);
|
||||
if (response.ok) {
|
||||
@ -150,6 +180,16 @@
|
||||
</div>
|
||||
{/await}
|
||||
</div>
|
||||
<div class="px-4 mb-4">
|
||||
<p>Bildgenerations-Model</p>
|
||||
<RadioGroup active="variant-filled-primary" hover="hover:variant-soft-primary">
|
||||
{#each models as model}
|
||||
<RadioItem bind:group={currentModel} value={model.value}>
|
||||
{model.name}
|
||||
</RadioItem>
|
||||
{/each}
|
||||
</RadioGroup>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
<form on:submit|preventDefault={handleSubmit} class="flex flex-col md:flex-row space-x-4">
|
||||
|
Loading…
Reference in New Issue
Block a user