Fix social previews and remove default style

This commit is contained in:
Mememan 2024-04-19 01:19:07 +02:00
parent 29f98ffd39
commit b60dcf06c8
5 changed files with 15 additions and 7 deletions

View file

@ -66,7 +66,7 @@ func parseConfig(name string, cfg *Config) (err error) {
cfg.AspectRatio = "1024*1024"
}
if len(cfg.Sampler) == 0 {
cfg.Sampler = "euler_a"
cfg.Sampler = "euler_ancestral"
}
if cfg.UserPromptBias == 0 {
cfg.UserPromptBias = 0.5

View file

@ -2,6 +2,10 @@
<html>
<head>
<title>{{ .Label.Title }}</title>
<meta charset="UTF-8">
<meta property="og:image" content="https://{{ .SocialURL }}" />
<meta property="og:description" content="{{ .Label.Title}}, {{ .Label.Date }}" />
<style>
body {
display: flex;
@ -48,7 +52,6 @@
font-weight: 300;
}
</style>
<meta property="og:image" content={{ .Img.URL }} />
</head>
<body>

View file

@ -32,6 +32,7 @@ type FooocusTxt2Img struct {
NegativePrompt string `json:"negative_prompt,omitempty"`
BaseModelName string `json:"base_model_name,omitempty"`
Loras []Lora `json:"loras,omitempty"`
Styles []string `json:"style_selections"`
AspectRatio string `json:"aspect_ratios_selection,omitempty"`
ImageSeed int `json:"image_seed,omitempty"`
Sharpness float64 `json:"sharpness,omitempty"`
@ -48,6 +49,7 @@ func buildTxt2ImgQuery(prompt string) (data []byte, err error) {
query.Api_name = "txt2img"
query.RequireBase64 = true // necessary
query.Styles = []string{""}
query.Loras = config.Loras
query.AspectRatio = config.AspectRatio
query.GuidanceScale = config.GuidanceScale

11
html.go
View file

@ -42,11 +42,12 @@ type Label struct {
}
type PageContent struct {
Img Img
Label Label
Img Img
Label Label
SocialURL string
}
func writeDisplayPage(w http.ResponseWriter, m FileData) (err error) {
func writeDisplayPage(w http.ResponseWriter, r *http.Request, m FileData) (err error) {
tmpl, err := template.New("display").Parse(displayTmpl)
if err != nil {
ErrorLogger.Println(err)
@ -74,7 +75,9 @@ func writeDisplayPage(w http.ResponseWriter, m FileData) (err error) {
Date: fmt.Sprintf("%d", m.Date.Year()),
Size: fmt.Sprintf("%s x %s cm", widthCm, heightCm),
Technique: m.Metadata["Technique"],
}}
},
SocialURL: r.Host + "/img.png",
}
err = tmpl.Execute(w, tmplData)
if err != nil {
ErrorLogger.Println(err)

View file

@ -87,7 +87,7 @@ func serveGallery(w http.ResponseWriter, r *http.Request) {
}
// Picture exists, let's show it
err = writeDisplayPage(w, FileData{
err = writeDisplayPage(w, r, FileData{
URL: "img.png",
Name: metadata.Key,
Size: metadata.Size,