gijl commited on
Commit
1f29c7c
·
verified ·
1 Parent(s): 5714db9

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +10 -0
  2. app.py +29 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM python:3.9
3
+ WORKDIR /app
4
+ RUN apt-get update && apt-get install -y build-essential python3-dev && rm -rf /var/lib/apt/lists/*
5
+ RUN pip install --no-cache-dir llama-cpp-python streamlit huggingface_hub
6
+ # Download the model file during build
7
+ RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='gijl/ai', filename='brain_map_v3_f16.gguf', local_dir='.')"
8
+ COPY . .
9
+ EXPOSE 7860
10
+ CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ from llama_cpp import Llama
4
+ import os
5
+
6
+ st.set_page_config(page_title='Brain Map AI - GGUF Engine', layout='wide')
7
+ st.title('🚀 Brain Map AI v3.0 (GGUF)')
8
+ st.markdown('**Engine:** llama.cpp (High Performance C++)')
9
+
10
+ @st.cache_resource
11
+ def load_gguf():
12
+ # In a real Space, we would download from the repo
13
+ # For this demo, we assume the file is mapped or downloaded
14
+ model_path = 'brain_map_v3_f16.gguf'
15
+ return Llama(model_path=model_path, n_ctx=512, n_threads=2)
16
+
17
+ try:
18
+ llm = load_gguf()
19
+ st.success('GGUF Engine Initialized')
20
+ except Exception as e:
21
+ st.error(f'Initialization Error: {e}')
22
+
23
+ query = st.text_input('Clinical Inquiry:')
24
+ if st.button('Compute'):
25
+ if query:
26
+ with st.spinner('Processing via llama.cpp...'):
27
+ output = llm(f'Q: {query} A:', max_tokens=150, stop=['Q:'], echo=False)
28
+ st.markdown('### Result:')
29
+ st.write(output['choices'][0]['text'])
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ llama-cpp-python
2
+ streamlit
3
+ huggingface_hub