from diffusers import StableDiffusionPipeline

[링크 : https://www.reddit.com/r/Python/comments/10g5nay/use_python_to_build_a_free_stable_diffusion_app/?tl=ko]

[링크 : https://www.assemblyai.com/blog/build-a-free-stable-diffusion-app-with-a-gpu-backend]

 

매모리 터져나갈게 보이니 e4b는 gpu 0번에서

stable diffusion은 gpu 1번에서 돌려서 두개 연동해

img2img로 장난치거나 그림 그려 가 포함되면 txt2img로 돌려도 괜찮을듯

---

by gpt

api 모드를 활성화 해주고

./webui.sh --api

 

txt2img

import requests
import base64

url = "http://127.0.0.1:7860/sdapi/v1/txt2img"

payload = {
    "prompt": "masterpiece, ultra detailed, cyberpunk girl, neon city, rain",
    "negative_prompt": "low quality, blurry",
    "steps": 30,
    "width": 768,
    "height": 768,
    "cfg_scale": 7,
    "sampler_name": "DPM++ 2M Karras"
}

response = requests.post(url, json=payload)

result = response.json()

# base64 이미지 저장
image_data = base64.b64decode(result["images"][0])

with open("generated.png", "wb") as f:
    f.write(image_data)

print("generated.png 저장 완료")

 

오.. 된다.

 

img2img

import requests
import base64

# 입력 이미지 읽기
with open("input.png", "rb") as f:
    image_base64 = base64.b64encode(f.read()).decode()

url = "http://127.0.0.1:7860/sdapi/v1/img2img"

payload = {
    "init_images": [image_base64],

    "prompt": "cyberpunk style, neon lights, futuristic",
    "negative_prompt": "low quality, blurry",

    "denoising_strength": 0.55,

    "steps": 30,
    "cfg_scale": 7,
    "width": 768,
    "height": 768,
    "sampler_name": "DPM++ 2M Karras"
}

response = requests.post(url, json=payload)

result = response.json()

image_data = base64.b64decode(result["images"][0])

with open("modified.png", "wb") as f:
    f.write(image_data)

print("modified.png 저장 완료")

 

[링크 : https://chatgpt.com/share/69fd90a2-2bbc-83e9-8f04-6cecdddc1b41]

Posted by 구차니

llama-swap / llama.cpp 설정

이상하게도 gemma4-e2b의 경우 용량이 작아서 그런가 -sm none을 안주면 오히려 에러가 난다.

$ cat config.yaml 
models:
  gemma4-e2b:
    cmd: /mnt/Downloads/llama-b8925/llama-server --port ${PORT} --model /mnt/Downloads/model/gemma4-e2b/gemma-4-E2B-it-Q4_K_M.gguf -mm ./model/gemma4-e2b/mmproj-F16.gguf -sm none
  gemma4-e4b:
    cmd: /mnt/Downloads/llama-b8925/llama-server --port ${PORT} --model /mnt/Downloads/model/gemma4-e4b/gemma-4-E4B-it-Q4_K_M.gguf -mm ./model/gemma4-e4b/mmproj-F16.gguf
  gemma4-26B_img:
    cmd: /mnt/Downloads/llama-b8925/llama-server --port ${PORT} --model /mnt/Downloads/model/gemma4-26b/gemma-4-26B-A4B-it-UD-IQ2_M.gguf -mm ./model/gemma4-26b/mmproj-F16.gguf
  qwen3.6-35b_img:
    cmd: /mnt/Downloads/llama-b8925/llama-server --port ${PORT} --model /mnt/Downloads/model/qwen3.6_35B/Qwen3.6-35B-A3B-UD-Q2_K_XL.gguf -mm ./model/qwen3.6_35B/mmproj-F16.gguf
  qwen3.6-35b:
    cmd: /mnt/Downloads/llama-b8925/llama-server --port ${PORT} --model /mnt/Downloads/model/qwen3.6_35B/Qwen3.6-35B-A3B-UD-Q2_K_XL.gguf

 

opencode 설정

이걸 추가한다고 바로 되는건 아닌 것 같고

~/.config/opencode$ cat opencode.json 
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "gemma4-e2b": {
          "name": "gemma4 e2b (local)",
          "limit": {
            "context": 128000,
            "output": 65536
          }
        }
      }
    }
  }
}

[링크 : https://opencode.ai/docs/providers#llamacpp]

 

opencode 에서 /connect 명령을 통해 좀 더 해주어야 로컬에서 돌아간다.

 

 

 

 

심심하니 한번 로컬로 작성 시도!

 

오오 로컬 잡아먹는다 ㅋㅋㅋ

(요건 gpu0 에 e2b / gpu1에는 stable diffusion)

 

opencode.json 파일 추가!

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "gemma4-e2b": {
          "name": "gemma4 e2b (local)",
          "limit": {
            "context": 128000,
            "output": 65536
          }
        },
        "qwen3.6-35b": {
          "name": "qwen3.6-35b (local)",
          "limit": {
            "context": 65536,
            "output": 65536
          }
        }
      }
    }
  }
}

 

gemma4-e2b 에서 qwen3.6-35b로 환승!

 

인사 받기 참 힘드네 ㅋㅋㅋ

 

그래도 100% 꾹꾹 하는데 소비전력은 150 W 급 * 2 이라..

Posted by 구차니

엥.. 왜 갑자기 안되지 싶은데

-sm none 으로 해결

Posted by 구차니

0 번 부터 시작임

Launching Web UI with arguments: --server-name=0.0.0.0 --device-id=1

[링크 : https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/10665]

Posted by 구차니

다시 해보니 telegram은 ogg로 보내는데 이걸 넣으면 wav가 아니라서 배째는거라

ffmpeg을 통해서 ogg를 wav로 바꾸고 하니 먼가 처리를 한다.

다만 소리 크기가 작아서 인가 은근히 인식율이 떨이지네.. (gemma4:e2b)

 

----

ollama 통해서 하고 있는데 미구현인가..

아니면  gemma4:e2b가 ollama에서 할 때 오디오는 미지원인건가... 이건 어떻게 확인하지?

그 와중에 왜 이미지로 인식하냐?

--- [Prompt to AI] (Model: gemma4:e2b) ---
[{'role': 'user', 'content': [{'type': 'text', 'text': '이 내용을 분석해줘'}, {'type': 'input_audio', 'input_audio': {'data': 'encoded data', 'format': 'wav'}}]}]


 {'error': {'message': 'Failed to create new sequence: failed to process inputs: imageunknown format', 'type': 'api_error', 'param': None, 'code': None}}
 

 

$ ollama show gemma4:e2b
  Model
    architecture        gemma4    
    parameters          5.1B      
    context length      131072    
    embedding length    1536      
    quantization        Q4_K_M    
    requires            0.20.0    

  Capabilities
    completion    
    vision        
    audio         
    tools         
    thinking      

  Parameters
    temperature    1       
    top_k          64      
    top_p          0.95    

  License
    Apache License               
    Version 2.0, January 2004    
    ...                          

 

import OpenAI from "openai";
const openai = new OpenAI();

// Fetch an audio file and convert it to a base64 string
const url = "https://cdn.openai.com/API/docs/audio/alloy.wav";
const audioResponse = await fetch(url);
const buffer = await audioResponse.arrayBuffer();
const base64str = Buffer.from(buffer).toString("base64");

const response = await openai.chat.completions.create({
  model: "gpt-audio",
  modalities: ["text", "audio"],
  audio: { voice: "alloy", format: "wav" },
  messages: [
    {
      role: "user",
      content: [
        { type: "text", text: "What is in this recording?" },
        { type: "input_audio", input_audio: { data: base64str, format: "wav" }}
      ]
    }
  ],
  store: true,
});

console.log(response.choices[0]);

[링크 : https://developers.openai.com/api/docs/guides/audio?example=audio-in]

 

 

[링크 : https://community.openai.com/t/how-can-i-pass-a-system-prompt-and-audio-user-input-to-get-a-text-output-back/1002483/3]

[링크 : https://github.com/ggml-org/llama.cpp/issues/21868]

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

llama.cpp gemma4:e2b 실행시 에러  (0) 2026.05.08
stable diffusion gpu 선택하기  (0) 2026.05.08
ollama multimodal gemma4:e2b 테스트  (0) 2026.05.07
opencode + llama.cpp  (0) 2026.05.06
llm tts?  (0) 2026.05.05
Posted by 구차니

어떻게 쓰지 싶었는데, 2025년 5월 15일 내용에 이미 아래의 모델들이 지원되고 있었다

[링크 : https://ollama.com/blog/multimodal-models]

[링크 :https://ollama.com/search?c=vision]

 

아래 파일 경로가

/home/minimonk/1804-lubuntu-default-wallpaper.png 인데

절대경로 넣어주면 알아서 읽어서 본다.

헐..(!)

 

$ ollama run gemma4:e2b
>>> what do you see in this image?  /home/minimonk/1804-lubuntu-default-wall
... paper.png
Added image '/home/minimonk/1804-lubuntu-default-wallpaper.png'
Thinking...
Here's a thinking process to analyze the image and generate the 
description:

1.  **Analyze the Request:** The user provided an image and asked, "what 
do you see in this image?"

2.  **Examine the Image (Visual Analysis):**
    *   **Overall Impression/Mood:** The image is dark, deep, atmospheric, 
and somewhat cosmic or abstract.
    *   **Colors:** The dominant colors are deep blues (teal/cyan), 
vibrant purples (magenta/violet), and some lighter, soft areas.
    *   **Texture/Pattern:** The background is not uniformly smooth. It 
features nebulous areas and scattered dots.
    *   **Specific Elements:**
        *   **Background:** Deep blue/purple gradient.
        *   **Texture/Effects:** There are faint, wispy clouds or nebulas, 
especially in the upper right area, suggesting a cosmic or smoky effect.
        *   **Particles:** Numerous small, scattered white or 
light-colored dots (specks of light/stars/dust) are distributed across the 
frame.
        *   **Light/Glow:** There is a soft, glowing, lighter purple/pink 
area, particularly visible towards the right.

3.  **Synthesize the Description (Drafting the Response):** Combine the 
observations into a coherent description. Start with the general theme and 
then detail the specific elements.

    *   *(Initial thought: It's a space background.)*
    *   *(Refinement: It's an abstract digital art piece, often called a 
cosmic or nebula background.)*

4.  **Review and Refine (Adding evocative language):** Ensure the 
description is accurate and engaging. (Self-Correction: Avoid making 
definitive claims like "it is space," but use terms that imply it, like 
"nebula" or "cosmic.")

5.  **Final Output Generation.** (This leads to the provided good 
response.)
...done thinking.

This image is an **abstract, atmospheric background**, often resembling a 
**cosmic or nebula scene**.

Here is a detailed breakdown of what I see:

1.  **Color Palette:** The dominant colors are deep and rich, featuring a 
strong gradient blend of **deep blues** and **vibrant purples/magentas**.
2.  **Texture/Atmosphere:** The background has a soft, smoky, or nebulous 
quality, suggesting deep space or an ethereal cloud formation. There are 
lighter, diffused areas, particularly on the right side, which glow with 
pink and purple hues.
3.  **Particles:** The image is scattered with numerous small, bright 
**white dots**, which give the impression of stars, dust, or glittering 
particles floating in the dark space.
4.  **Overall Mood:** The image evokes a feeling of depth, mystery, 
serenity, and vastness. It is highly typical of digital art used as 
wallpapers or abstract graphics.

 

llama.cpp로 개고생 하던게 이렇게 쉽게 되다니 ㅠㅠ

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

stable diffusion gpu 선택하기  (0) 2026.05.08
openai api .. 오디오 처리 성공  (0) 2026.05.07
opencode + llama.cpp  (0) 2026.05.06
llm tts?  (0) 2026.05.05
stablie diffusion 모델 변경 / 다운로드 하기  (0) 2026.05.05
Posted by 구차니

요즘 핫하던데 (엄청난 비용의 토큰을 쓴 경험을 바탕으로 한국인이 만들었다고)

local llm에도 붙일수 있어서 한번 해봐야 할 듯.

gui 시대에 tui라니 끌리는데? ㅋㅋ

[링크 : https://www.elancer.co.kr/blog/detail/1048]

[링크 : https://wikidocs.net/338090]

[링크 : https://opencode.ai/ko]

 

llama.cpp
llama.cpp의 llama-server 유틸리티를 통해 로컬 모델을 사용하도록 구성할 수 있습니다.

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "llama.cpp": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "llama-server (local)",
      "options": {
        "baseURL": "http://127.0.0.1:8080/v1"
      },
      "models": {
        "qwen3-coder:a3b": {
          "name": "Qwen3-Coder: a3b-30b (local)",
          "limit": {
            "context": 128000,
            "output": 65536
          }
        }
      }
    }
  }
}

이 예제에서:

llama.cpp는 사용자 정의 공급자 ID입니다. 원하는 문자열로 지정할 수 있습니다.
npm은 이 공급자에 사용할 패키지를 지정합니다. 여기서는 OpenAI 호환 API를 위해 @ai-sdk/openai-compatible을 사용합니다.
name은 UI에 표시될 공급자 이름입니다.
options.baseURL은 로컬 서버의 엔드포인트입니다.
models는 모델 ID와 해당 구성을 매핑합니다. 모델 이름은 모델 선택 목록에 표시됩니다.

[링크 : https://opencode.ai/docs/providers/]

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

openai api .. 오디오 처리 성공  (0) 2026.05.07
ollama multimodal gemma4:e2b 테스트  (0) 2026.05.07
llm tts?  (0) 2026.05.05
stablie diffusion 모델 변경 / 다운로드 하기  (0) 2026.05.05
gemma4 e?b 멀티모달  (0) 2026.05.05
Posted by 구차니

llama-outeTTS 가 많이 검색되어 나오는데 한번 돌려봐야 할 듯.

확장자가 safetensor로 되어있고

[링크 : https://huggingface.co/unsloth/Llama-OuteTTS-1.0-1B/tree/main]

 

걍 -m 뒤에 넣어줘보면 될 듯.

[링크 : https://github.com/ggml-org/llama.cpp/issues/688]

 

[링크 : https://huggingface.co/unsloth/Llama-OuteTTS-1.0-1B]

[링크 : https://github.com/ggml-org/llama.cpp/discussions/11679]

[링크 : https://www.reddit.com/r/LocalLLaMA/comments/1l0qbot/tts_support_in_llamacpp/?tl=ko]

[링크 : https://arca.live/b/aispeech/136125630]

Posted by 구차니

음.. 받고 리프레시 하면 바로 뜨는듯?

다운로드한 파일을 이제 'C://StableDiffusion/stable-diffusion-webui/models/Stable-diffusion' 경로에 이동해서 넣으시면 됩니다. (이태릭체는 설치한 경로예요.)

[링크 : https://selgyun.tistory.com/entry/Stable-Diffusion-체크-포인트Checkpoint-학습-모델-추가하기-SD-2]

 

먼가 추천 링크들 보면 이런게 떠서 가입을 해야만 한다고 하니 귀찮...

아무튼 여기서 illustrious 로 검색하라는데 그게 모델명인가?

[링크 : https://civitai.com/]

 

 

+

2026.05.06

실행하면 하나 밖에 없었는데

 

위의 경로에 하나 넣고 우측의 refresh 을 눌러보니

 

오옹~!

250W 거의 풀로 먹고 83도.. ㄷㄷㄷ

 

근데 모델을 바꾸어도

내가 원하는걸 그리는건 또 다른 문제구나.

예제대로 해봐도 똑같이 안나온다.

 

 

1girl, masterpiece, general, lineart, white background, simple background
Negative prompt: bad quality,low quality,worst quality,lowres,displeasing,very displeasing,bad,bad anatomy,bad hands,text,error, multiple views, messy, amateur, blurry, blurry background, blurry foreground, rough, roughly drawn, messy, bad, what, guro, gore, futanari, yaoi, bara, pectorals, Steps: 28, CFG scale: 7.5, Sampler: Euler a, Seed: 1790244969, Size: 832x1216, Model: Illustrious-XL-v0.1, Version: f1.0.2-v1.10.1RC-latest-691-g37223711, Model hash: 3e15ba0038, Schedule type: Automatic, Discard penultimate sigma: True

 

1girl, masterpiece, general, lineart, white background, simple background
Negative prompt: worst quality,bad quality,bad hands,very displeasing,extra digit,fewer digits,jpeg artifacts,signature,username,reference,mutated,lineup,manga,comic,disembodied,futanari,yaoi,dickgirl,turnaround,2koma,4koma,monster,cropped,amputee,text,bad foreshortening,what,guro,logo,bad anatomy,bad perspective,bad proportions,artistic error,anatomical nonsense,amateur,out of frame,multiple views,weibo username,
Steps: 28, Sampler: Euler a, Schedule type: Automatic, CFG scale: 7.5, Seed: 1790244969, Size: 768x1024, Model hash: 3e15ba0038, Model: illustriousXL_v01, Version: v1.10.1-96-g1937682a

같은 시드라도 다르게 나오나?

 

Discard penultimate sigma: True 를 설정하려면 settings - Sampler parameters - Always discard next-to-list sigma를 체크하고 apply 하면 되나본데..

[링크 : https://github.com/AUTOMATIC1111/stable-diffusion-webui/discussions/14169]

 

다시보니 negative prompt 문제인것 같은데 다시 해봐도 같은건 안나온다. 그림 해상도 영향도 받나?

 

먼가.. 확대하니 이상하다. 그리고 그림도 다르게 나오네 

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

opencode + llama.cpp  (0) 2026.05.06
llm tts?  (0) 2026.05.05
gemma4 e?b 멀티모달  (0) 2026.05.05
stable diffusion + 1080 ti 시도  (0) 2026.05.04
stable diffusion + pytorch 관련 조사  (0) 2026.05.04
Posted by 구차니

어..?!

31b가 오히려 audio를 지원하지 않는다.

 

qwen3.6 이나 gemma4 31B 이런애들만 되는 줄 알았는데, e2b e4b 에서도 되서 시도!

6. Audio
Use the following prompt structures for audio processing:

Audio Speech Recognition (ASR)
Transcribe the following speech segment in {LANGUAGE} into {LANGUAGE} text.

Follow these specific instructions for formatting the answer:
* Only output the transcription, with no newlines.
* When transcribing numbers, write the digits, i.e. write 1.7 and not one point seven, and write 3 instead of three.

Automatic Speech Translation (AST)
Transcribe the following speech segment in {SOURCE_LANGUAGE}, then translate it into {TARGET_LANGUAGE}.
When formatting the answer, first output the transcription in {SOURCE_LANGUAGE}, then one newline, then output the string '{TARGET_LANGUAGE}: ', then the translation in {TARGET_LANGUAGE}.

[링크 : https://huggingface.co/google/gemma-4-E2B]

[링크 : https://huggingface.co/unsloth/gemma-4-E4B-it-GGUF/tree/main]

 

+

실행은 아래와 같이 해주고

D:\study\llm\llama-b8916-bin-win-vulkan-x64>llama-server.exe -m ..\gemma-4-E4B-it-Q4_K_M.gguf --mmproj ..\mmproj-F16.gguf

 

심심하니 nvidia-smi 스샷찍어둔걸 사골로 우려먹기 ㅋㅋ

 

골든 mp4로 받고 ffmpeg 으로 mp3 변환하고

[링크 : https://www.youtube.com/watch?v=yebNIHKAC4A]

 

 

구글 검색에서 뜨는 가사랑 diff 떠보니 음.. 맞는것 같으면서 안 맞는

그래도 노래를 TTS로 돌린거 치고는 제법 비슷하게 나왔다는게 대단한 듯.

'프로그램 사용 > ai 프로그램' 카테고리의 다른 글

llm tts?  (0) 2026.05.05
stablie diffusion 모델 변경 / 다운로드 하기  (0) 2026.05.05
stable diffusion + 1080 ti 시도  (0) 2026.05.04
stable diffusion + pytorch 관련 조사  (0) 2026.05.04
stable diffusion 관련  (0) 2026.05.02
Posted by 구차니