jean commited on
Commit
73abdf6
·
1 Parent(s): 4789c07

fix arm image problem

Browse files
Files changed (8) hide show
  1. .dockerignore +26 -0
  2. Dockerfile +19 -8
  3. app.py +1 -1
  4. llms/qwen.py +0 -27
  5. main.py +21 -25
  6. pyproject.toml +26 -0
  7. requirements.txt +0 -16
  8. uv.lock +0 -0
.dockerignore ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore Python cache
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+
7
+ # Ignore virtual environments
8
+ .venv
9
+
10
+ # Ignore development tools
11
+ *.log
12
+ *.swp
13
+ .DS_Store
14
+
15
+ # Ignore Git
16
+ .git
17
+ .gitignore
18
+
19
+ # Ignore Docker files not needed in build context
20
+ docker-compose.yml
21
+ docker-compose.override.yml
22
+
23
+ # Ignore tests and docs if not needed
24
+ tests/
25
+ docs/
26
+ uv.look
Dockerfile CHANGED
@@ -1,12 +1,23 @@
1
- FROM python:3.10-slim
 
 
 
 
 
 
 
 
 
 
2
 
3
- RUN apt-get update && apt-get install -y build-essential cmake
4
-
5
- COPY requirements.txt .
 
 
6
 
7
- RUN pip install --upgrade pip && pip install -r requirements.txt
8
 
9
- COPY . /app
10
- WORKDIR /app
11
 
12
- CMD ["python", "app.py"]
 
1
+ FROM --platform=linux/amd64 python:3.11-slim
2
+ RUN apt-get update && apt-get install -y \
3
+ make \
4
+ curl \
5
+ ca-certificates \
6
+ build-essential \
7
+ cmake \
8
+ nano\
9
+ pkg-config \
10
+ libopenblas-dev \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ RUN curl -Ls https://astral.sh/uv/install.sh | bash
14
+ ENV PATH="/root/.cargo/bin:/root/.local/bin:${PATH}"
15
+ WORKDIR /app
16
+ COPY . .
17
+ RUN which uv || echo "uv not found"
18
 
19
+ ENV CMAKE_ARGS="-DGGML_USE_OPENMP=ON -DGGML_BLAS=ON -DGGML_BLAS_VENDOR=OpenBLAS"
20
 
21
+ RUN uv add llama-cpp-python
 
22
 
23
+ CMD ["uv", "run", "app.py"]
app.py CHANGED
@@ -97,4 +97,4 @@ with gr.Blocks() as demo:
97
  show_progress=True # 🛠️ Important when using async fn
98
  )
99
 
100
- demo.launch()
 
97
  show_progress=True # 🛠️ Important when using async fn
98
  )
99
 
100
+ demo.launch(share=True)
llms/qwen.py CHANGED
@@ -1,9 +1,4 @@
1
  from huggingface_hub import hf_hub_download
2
- from langchain_huggingface import HuggingFacePipeline
3
- from transformers import pipeline
4
- from langchain_community.llms import LlamaCpp
5
- from langchain_core.callbacks import CallbackManager, StreamingStdOutCallbackHandler
6
- from langchain_core.runnables import RunnableLambda
7
  from llama_cpp import Llama
8
  from llama_cpp.llama_chat_format import Qwen25VLChatHandler
9
 
@@ -28,26 +23,4 @@ qwen_model = Llama(
28
  use_mlock=True, # Facultatif mais recommandé si tu veux garder en RAM
29
  offload_kv=True, # Offload KV cache sur le GPU (important)
30
  verbose=True ,
31
-
32
  )
33
-
34
- # messages = [
35
- # {
36
- # "role": "user",
37
- # "content": [
38
- # {
39
- # "type": "text",
40
- # "text": "Describe this image in one sentence."
41
- # },
42
- # {
43
- # "type": "image_url",
44
- # "image_url": {
45
- # "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
46
- # }
47
- # }
48
- # ]
49
- # }
50
- # ]
51
-
52
-
53
- # qwen_model = RunnableLambda(lambda messages: llm.create_chat_completion(messages=messages))
 
1
  from huggingface_hub import hf_hub_download
 
 
 
 
 
2
  from llama_cpp import Llama
3
  from llama_cpp.llama_chat_format import Qwen25VLChatHandler
4
 
 
23
  use_mlock=True, # Facultatif mais recommandé si tu veux garder en RAM
24
  offload_kv=True, # Offload KV cache sur le GPU (important)
25
  verbose=True ,
 
26
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
main.py CHANGED
@@ -1,27 +1,23 @@
1
- from llama_cpp import Llama
2
 
3
- llm = Llama.from_pretrained(
4
- repo_id="unsloth/Qwen2.5-VL-3B-Instruct-GGUF",
5
- filename="Qwen2.5-VL-3B-Instruct-BF16.gguf",
6
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
-
9
- llm.create_chat_completion(
10
- messages = [
11
- {
12
- "role": "user",
13
- "content": [
14
- {
15
- "type": "text",
16
- "text": "Describe this image in one sentence."
17
- },
18
- {
19
- "type": "image_url",
20
- "image_url": {
21
- "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
22
- }
23
- }
24
- ]
25
- }
26
- ]
27
- )
 
1
+ import time
2
 
3
+ def main():
4
+ try:
5
+ # Try to import and run your actual logic
6
+ from services.analyse_image import ErrorResponse, analyze_image
7
+ # You can also call a Flask/Gradio/FastAPI app here if needed
8
+ print("Application started successfully.")
9
+ # Keep running (e.g., start a web server or background process)
10
+ while True:
11
+ time.sleep(60)
12
+ except ImportError as e:
13
+ print(f"[ImportError] Could not load some modules: {e}")
14
+ except Exception as e:
15
+ print(f"[Startup Error] {e}")
16
+ finally:
17
+ # Keep the container alive even if errors happen
18
+ print("Container is running in idle mode for debugging.")
19
+ while True:
20
+ time.sleep(3600)
21
 
22
+ if __name__ == "__main__":
23
+ main()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pyproject.toml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "object-analyser"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ dependencies = [
8
+ "dotenv>=0.9.9",
9
+ "gradio>=5.38.1",
10
+ "huggingface-hub>=0.34.1",
11
+ "jinja2>=3.1.6",
12
+ "langchain>=0.3.27",
13
+ "langchain-community>=0.3.27",
14
+ "langchain-huggingface>=0.3.1",
15
+ "langchain-ollama>=0.3.6",
16
+ "langchainhub>=0.1.21",
17
+ "langgraph>=0.5.4",
18
+ "pillow>=11.3.0",
19
+ "python-multipart>=0.0.20",
20
+ "text-generation>=0.7.0",
21
+ "torch>=2.7.1",
22
+ "torchvision>=0.22.1",
23
+ "transformers>=4.53.3",
24
+ ]
25
+
26
+
requirements.txt DELETED
@@ -1,16 +0,0 @@
1
- dotenv>=0.9.9
2
- gradio>=5.38.1
3
- huggingface-hub>=0.34.1
4
- jinja2>=3.1.6
5
- langchain>=0.3.27
6
- langchain-community>=0.3.27
7
- langchain-huggingface>=0.3.1
8
- langchain-ollama>=0.3.6
9
- langchainhub>=0.1.21
10
- langgraph>=0.5.4
11
- llama-cpp-python>=0.3.14
12
- python-multipart>=0.0.20
13
- text-generation>=0.7.0
14
- torch>=2.7.1
15
- torchvision>=0.22.1
16
- transformers>=4.53.3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uv.lock ADDED
The diff for this file is too large to render. See raw diff