Do0rMaMu commited on
Commit
6d22f9b
·
verified ·
1 Parent(s): afc4fb1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -2
Dockerfile CHANGED
@@ -10,8 +10,24 @@ COPY requirements.txt /code/requirements.txt
10
  # Install any dependencies specified in requirements.txt
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Download the Florence-2-base-ft model and processor
14
- RUN python -c "from transformers import AutoModelForCausalLM, AutoProcessor; model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base-ft', trust_remote_code=True); processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base-ft', trust_remote_code=True); model.save_pretrained('/code/florence_model'); processor.save_pretrained('/code/florence_processor')"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  # Copy the current directory contents into the container at /code
17
  COPY . .
 
10
  # Install any dependencies specified in requirements.txt
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Apply the patch to remove flash-attn dependency and download the Florence-2-base-ft model and processor
14
+ RUN python -c "\
15
+ import os; \
16
+ from unittest.mock import patch; \
17
+ from transformers import AutoModelForCausalLM, AutoProcessor; \
18
+ from transformers.dynamic_module_utils import get_imports; \
19
+ def fixed_get_imports(filename: os.PathLike) -> list[str]: \
20
+ if not str(filename).endswith('/modeling_florence2.py'): \
21
+ return get_imports(filename); \
22
+ imports = get_imports(filename); \
23
+ if 'flash_attn' in imports: \
24
+ imports.remove('flash_attn'); \
25
+ return imports; \
26
+ with patch('transformers.dynamic_module_utils.get_imports', fixed_get_imports): \
27
+ model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base-ft', trust_remote_code=True); \
28
+ processor = AutoProcessor.from_pretrained('microsoft/Florence-2-base-ft', trust_remote_code=True); \
29
+ model.save_pretrained('/code/florence_model'); \
30
+ processor.save_pretrained('/code/florence_processor');"
31
 
32
  # Copy the current directory contents into the container at /code
33
  COPY . .