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 구차니
embeded/FPGA - ALTERA2026. 5. 8. 12:28

9년 전에 조사한 적이 있었네 -_-

2017.12.26 - [embeded/FPGA - ALTERA] - GHDL - 시뮬레이터

 

$ ghdl
Command 'ghdl' not found, but can be installed with:
sudo snap install ghdl         # version 3.0.0, or
sudo apt  install ghdl-common  # version 1.0.0+dfsg-6
See 'snap info ghdl' for additional versions.

$ sudo apt  install ghdl-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  ghdl-common
0 upgraded, 1 newly installed, 0 to remove and 54 not upgraded.
Need to get 154 kB of archives.
After this operation, 2,444 kB of additional disk space will be used.
Get:1 http://kr.archive.ubuntu.com/ubuntu jammy/universe amd64 ghdl-common amd64 1.0.0+dfsg-6 [154 kB]
Fetched 154 kB in 0s (4,318 kB/s)   
Selecting previously unselected package ghdl-common.
(Reading database ... 304538 files and directories currently installed.)
Preparing to unpack .../ghdl-common_1.0.0+dfsg-6_amd64.deb ...
Unpacking ghdl-common (1.0.0+dfsg-6) ...
Setting up ghdl-common (1.0.0+dfsg-6) ...
Processing triggers for man-db (2.10.2-1) ...

$ sudo apt-get install ghdl*
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'ghdl-gcc' for glob 'ghdl*'
Note, selecting 'ghdl-mcode' for glob 'ghdl*'
Note, selecting 'ghdl-common' for glob 'ghdl*'
Note, selecting 'ghdl-llvm' for glob 'ghdl*'
Note, selecting 'ghdl' for glob 'ghdl*'
ghdl-common is already the newest version (1.0.0+dfsg-6).
The following additional packages will be installed:
  gcc-10-base libgnat-10
Suggested packages:
  gtkwave
The following NEW packages will be installed:
  gcc-10-base ghdl ghdl-gcc ghdl-llvm ghdl-mcode libgnat-10
0 upgraded, 6 newly installed, 0 to remove and 54 not upgraded.
Need to get 15.5 MB of archives.
After this operation, 60.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y 

 

[링크 : https://github.com/ghdl/setup-ghdl]

[링크 : https://askubuntu.com/questions/1199027/ghdl-in-ubuntu-18-040-lts-gtkwave-vlsi-fpga-vhdl]

[링크 : https://github.com/ghdl/ghdl/releases]

 

by gpt  

test.vhd
entity test is
end;

architecture sim of test is
begin
    process
    begin
        report "Hello GHDL";
        wait;
    end process;
end;

컴파일:

ghdl -a test.vhd

엘라보레이션:

ghdl -e test

실행:

ghdl -r test

출력:

Hello GHDL
5. GTKWave 함께 설치 (파형 보기)

보통 같이 설치합니다.

sudo apt install gtkwave

VCD 생성 실행 예시:

ghdl -r test --vcd=test.vcd
gtkwave test.vcd

 

먼가 되긴한데.. 문법이 다른가?

$ cat test.vhd 
entity test is
end;

architecture sim of test is
begin
    process
    begin
        report "Hello GHDL";
        wait;
    end process;
end;

$ ghdl -a 7seg.vhdl 


$ ghdl -r test
test.vhd:8:9:@0ms:(report note): Hello GHDL

$ ghdl -r test --vcd=test.vcd
test.vhd:8:9:@0ms:(report note): Hello GHDL

$ gtkwave test.vcd
Gtk-Message: 12:29:46.165: Failed to load module "canberra-gtk-module"

GTKWave Analyzer v3.3.104 (w)1999-2020 BSI

No symbols in VCD file..nothing to do!


$ sudo apt install libcanberra-gtk-module libcanberra-gtk3-module


$ gtkwave test.vcd

GTKWave Analyzer v3.3.104 (w)1999-2020 BSI

No symbols in VCD file..nothing to do!

$ cat test.vcd
$date
  Fri May  8 12:29:32 2026
$end
$version
  GHDL v0
$end
$timescale
  1 fs
$end
$scope module standard $end
$upscope $end
$scope module test $end
$upscope $end
$enddefinitions $end
#0


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 구차니
Programming/qt2026. 5. 7. 15:13

내가 원하던  mainwindow의 내용을 다른 위젯으로 변경하기

[링크 : https://doc.qt.io/qt-6/qmainwindow.html#setCentralWidget]

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

 

새 다이얼로그 창을 열고 숨기기

[링크 : https://toytvstory.tistory.com/1422]


replacewidget()

주로 한개의 위젯을 바꾸지, 창을 바꾸는 용도는 아닌듯?

[링크 : https://stackoverflow.com/questions/35382622/replace-a-widget-in-qt]

[링크 : https://doc.qt.io/qt-6/qlayout.html#replaceWidget]

 

 

'Programming > qt' 카테고리의 다른 글

QPushButton 에서 이미지로 대체하기  (0) 2026.04.29
QT QLabel 배경색상 넣기  (0) 2026.04.29
qt creator ui 파일 관련  (0) 2026.04.29
qt5 gif 애니메이션  (0) 2026.04.28
qt5 다국어 지원 테스트  (0) 2026.04.28
Posted by 구차니
Linux/Ubuntu2026. 5. 6. 22:29

예전에 우분투에서 이상하게 반응이 느렸던 문제로 찾았던건데

llm 에서 한글 발음을 영어로 적게 해서 이걸 festival 통해 wav로 생성하고

메신저로 넘기게 하면 어떨려나?

 

echo "linuxquestions.org" > mytext.txt
text2wave -o mytext.wav myaudio.txt

[링크 : https://wiki.linuxquestions.org/wiki/Text2wave]

[링크 : https://wiki.archlinux.org/title/Festival]

[링크 : https://manpages.ubuntu.com/manpages/resolute/man1/festival.1.html]

[링크 : https://manpages.ubuntu.com/manpages/trusty/man1/text2wave.1.html]

 

+

2026.05.07

ai 가라사대~

설치된 음성은 festival 실행해서 괄호넣어서 하면 나오는데

$ festival

Festival Speech Synthesis System 2.5.0:release December 2017
Copyright (C) University of Edinburgh, 1996-2010. All rights reserved.

clunits: Copyright (C) University of Edinburgh and CMU 1997-2010
clustergen_engine: Copyright (C) Carnegie Mellon University 2005-2017
hts_engine: 
The HMM-Based Speech Synthesis Engine "hts_engine API"
hts_engine API version 1.07 (http://hts-engine.sourceforge.net/)
Copyright (C) The HMM-Based Speech Synthesis Engine "hts_engine API"
Version 1.07 (http://hts-engine.sourceforge.net/)
Copyright (C) 2001-2012 Nagoya Institute of Technology
              2001-2008 Tokyo Institute of Technology
All rights reserved.

All rights reserved.
For details type `(festival_warranty)'
festival> voice.list
#<CLOSURE nil (begin "(voice.list)
List of all (potential) voices in the system.  This checks the voice-location
list of potential voices found be scanning the voice-path at start up time.
These names can be used as arguments to voice.description and
voice.describe." (mapcar car voice-locations))>
festival> (voice.list) 
(kal_diphone)

 

festvox로 추가 음성을 설치할 수 있다고 한다.

$ apt-cache search festvox*
flite - Small run-time speech synthesis engine
flite1-dev - Small run-time speech synthesis engine - development files
freetts - 음성 합성 시스템
libflite1 - 작은 런타임 음성 합성 엔진 - 공유 라이브러리
festvox-ca-ona-hts - Catalan female speaker for festival, 16kHz HTS
festvox-czech-dita - Czech adult female speaker "dita" for Festival
festvox-czech-krb - Czech child male speaker "krb" for Festival
festvox-czech-machac - Czech adult male speaker "machac" for Festival
festvox-czech-ph - Czech male speaker for Festival
festvox-hi-nsk - Hindi male speaker for festival
festvox-italp16k - Italian female speaker for Festival
festvox-itapc16k - Italian male speaker for Festival
festvox-kallpc16k - American English male speaker for festival, 16khz sample rate
festvox-kallpc8k - American English male speaker for festival, 8khz sample rate
festvox-kdlpc16k - American English male speaker for festival, 16khz sample rate
festvox-kdlpc8k - American English male speaker for festival, 8khz sample rate
festvox-mr-nsk - Marathi male speaker for festival
festvox-ru - Russian male speaker for Festival
festvox-suopuhe-common - Common files for Festival Finnish speakers
festvox-suopuhe-lj - Finnish female speaker for Festival
festvox-suopuhe-mv - Finnish male speaker for festival
festvox-te-nsk - Telugu (te) male speaker for festival
festvox-us-slt-hts - : US English voice for Festival. 32kHz sample rate, HTS
festvox-don - minimal British English male speaker for festival
festvox-ellpc11k - Castilian Spanish male speaker for Festival
festvox-en1 - mbrola-en1 voice support for festival
festvox-rablpc16k - British English male speaker for festival, 16khz sample rate
festvox-rablpc8k - British English male speaker for festival, 8khz sample rate
festvox-us1 - mbrola-us1 voice support for festival
festvox-us2 - mbrola-us2 voice support for festival
festvox-us3 - mbrola-us3 voice support for festival

 

echo "Hello" | festival --tts --voice voice_kal_diphone

(Parameter.set 'Duration_Stretch 1.3) ; 느리게
(set! duffint_params '((start 120) (end 140))) ; 피치 변경

 

For example
will make everything speak more slowly.

[링크 : https://www.cstr.ed.ac.uk/projects/festival/manual/festival_19.html#SEC72]

  [링크 : https://www.cstr.ed.ac.uk/projects/festival/manual/]

 

festival> help
"The Festival Speech Synthesizer System: Help

Getting Help
  (doc '<SYMBOL>)   displays help on <SYMBOL>
  (manual nil)      displays manual in local netscape
  C-c               return to top level
  C-d or (quit)     Exit Festival
(If compiled with editline)
  M-h               displays help on current symbol  
  M-s               speaks help on current symbol  
  M-m               displays relevant manual page in local netscape
  TAB               Command, symbol and filename completion
  C-p or up-arrow   Previous command
  C-b or left-arrow Move back one character
  C-f or right-arrow 
                    Move forward one character
  Normal Emacs commands work for editing command line

Doing stuff
  (SayText TEXT)      Synthesize text, text should be surrounded by
                      double quotes
  (tts FILENAME nil)  Say contexts of file, FILENAME should be 
                      surrounded by double quotes
  (voice_rab_diphone) Select voice (Britsh Male)
  (voice_kal_diphone) Select voice (American Male)
"

 

 

'Linux > Ubuntu' 카테고리의 다른 글

luit  (0) 2026.03.23
ubuntu 22.04 bgr 패널 대응  (0) 2025.12.29
clamav  (0) 2025.12.22
evince (리눅스 pdf 뷰어) 네비게이션  (0) 2025.12.11
ubuntu 22.04 bgr subpixel 대응 찾기 실패  (0) 2025.11.25
Posted by 구차니

N - Number of image size in batch size

H - Height of image

W - Width of image

C- number of Channel of the image

 

NCHW는 Channel First (red channel image + blue ...)

NHWC는 Channel Last (rgb pixel image)

 

[링크 : https://intel.github.io/intel-extension-for-pytorch/cpu/latest/tutorials/features/nhwc.html]

 

어떻게 보면 레이어 별로 처리하게 하는게 유리할수도 있을 것 같기도 한데 서로 tradeoff가 존재할 것 같다.

 

NCHW - (64,3,512,512)

NHWC - (64,512,512,3)

[링크 : https://medium.com/@gonchogo/nhwc-vs-nchw-1504d2621b5e]

 

GPU - NCHW

CPU - NHWC

tensorRT는 NHWC에서 최고의 효율

[링크 : https://seungwoo-dev.tistory.com/6]

Posted by 구차니