Sharim Jamal commited on
Commit
4445a35
Β·
1 Parent(s): fd03d77

docker fix

Browse files
Files changed (5) hide show
  1. .huggingface.yml +9 -1
  2. Dockerfile +35 -0
  3. README.md +62 -14
  4. app.py +6 -1
  5. requirements.txt +2 -1
.huggingface.yml CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
1
  sdk: gradio
2
  sdk_version: 5.38.0
3
- app_file: app.py
 
 
 
 
 
1
+ title: Agriscience
2
+ emoji: 🌍
3
+ colorFrom: green
4
+ colorTo: blue
5
  sdk: gradio
6
  sdk_version: 5.38.0
7
+ app_file: app.py
8
+ base: docker
9
+ pinned: false
10
+ license: mit
11
+ short_description: This space is for the contract review project
Dockerfile ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONUNBUFFERED=1
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Install system dependencies (avoiding problematic packages)
8
+ RUN apt-get update && apt-get install -y \
9
+ tesseract-ocr-all \
10
+ poppler-utils \
11
+ git \
12
+ wget \
13
+ && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Create user for Hugging Face Spaces
16
+ RUN useradd -m -u 1000 user
17
+ USER user
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
+
21
+ # Set working directory
22
+ WORKDIR $HOME/app
23
+
24
+ # Copy requirements and install Python dependencies
25
+ COPY --chown=user requirements.txt .
26
+ RUN pip install --no-cache-dir --user -r requirements.txt
27
+
28
+ # Copy application files
29
+ COPY --chown=user . .
30
+
31
+ # Expose port for Gradio
32
+ EXPOSE 7860
33
+
34
+ # Run the application
35
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,14 +1,62 @@
1
- ---
2
- title: Agriscience
3
- emoji: 🌍
4
- colorFrom: green
5
- colorTo: blue
6
- sdk: docker
7
- sdk_version: 5.42.0
8
- app_file: app.py
9
- pinned: false
10
- license: mit
11
- short_description: This space is for the contract review project
12
- ---
13
-
14
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agriscience Contract Auditor
2
+
3
+ ## 🎯 Overview
4
+ A Gradio-based web application that audits employment contracts against labor laws from different countries using AI-powered analysis through Flowise.
5
+
6
+ ## πŸ”§ Features
7
+ - **Multi-format support**: PDF, DOCX, TXT files
8
+ - **Multilingual processing**: English and Arabic text extraction
9
+ - **OCR capabilities**: Advanced Arabic PDF processing using Tesseract
10
+ - **Country-specific analysis**: USA, Germany, UAE, Turkey, Jordan
11
+ - **AI-powered auditing**: Connected to Flowise for intelligent contract analysis
12
+
13
+ ## πŸš€ Deployment
14
+
15
+ ### Hugging Face Spaces
16
+ This application is configured for deployment on Hugging Face Spaces using Docker.
17
+
18
+ **Files:**
19
+ - `Dockerfile`: Custom Docker configuration avoiding problematic system packages
20
+ - `.huggingface.yml`: Hugging Face Spaces configuration
21
+ - `requirements.txt`: Python dependencies
22
+ - `packages.txt`: System packages (Tesseract OCR, Poppler)
23
+ - `app.py`: Main Gradio application
24
+
25
+ ### Local Development
26
+ ```bash
27
+ # Install system dependencies (Ubuntu/Debian)
28
+ sudo apt-get update
29
+ sudo apt-get install tesseract-ocr-all poppler-utils
30
+
31
+ # Install Python dependencies
32
+ pip install -r requirements.txt
33
+
34
+ # Run the application
35
+ python app.py
36
+ ```
37
+
38
+ ## πŸ” Technical Details
39
+
40
+ ### Dependencies
41
+ - **Gradio**: Web interface framework
42
+ - **multilingual-pdf2text**: Advanced PDF text extraction
43
+ - **pdfplumber**: Standard PDF processing
44
+ - **pytesseract**: OCR engine integration
45
+ - **langdetect**: Language detection for smart processing
46
+
47
+ ### Architecture
48
+ 1. **File Upload**: Supports multiple formats
49
+ 2. **Text Extraction**: Smart extraction based on language detection
50
+ 3. **AI Analysis**: Sends extracted text to Flowise API
51
+ 4. **Results Display**: Formatted audit results in selected language
52
+
53
+ ## πŸ› οΈ Configuration
54
+ - **Flowise URL**: Configured for SIRA Flow application
55
+ - **Supported Countries**: USA, Germany, UAE, Turkey, Jordan
56
+ - **Response Languages**: English, Arabic
57
+
58
+ ## πŸ“ Usage
59
+ 1. Select target country for labor law compliance
60
+ 2. Choose response language (English/Arabic)
61
+ 3. Upload contract file (PDF/DOCX/TXT)
62
+ 4. Click "Audit Contract" to get AI-powered analysis
app.py CHANGED
@@ -140,4 +140,9 @@ with gr.Blocks(title="Contract Auditor") as demo:
140
  outputs=output
141
  )
142
 
143
- demo.launch()
 
 
 
 
 
 
140
  outputs=output
141
  )
142
 
143
+ if __name__ == "__main__":
144
+ demo.launch(
145
+ server_name="0.0.0.0",
146
+ server_port=7860,
147
+ show_error=True
148
+ )
requirements.txt CHANGED
@@ -3,4 +3,5 @@ requests
3
  pdfplumber
4
  docx2txt
5
  langdetect
6
- pytesseract
 
 
3
  pdfplumber
4
  docx2txt
5
  langdetect
6
+ multilingual-pdf2text
7
+ pytesseract