sagar4tech commited on
Commit
7dfb744
1 Parent(s): 93f683b

Upload 3 files

Browse files

app.py and requirements.txt (to setup local env ) for "text-to-image model inferencing locally on device "

Files changed (3) hide show
  1. README.md +1 -0
  2. app.py +21 -0
  3. requirements.txt +78 -0
README.md CHANGED
@@ -9,5 +9,6 @@ app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  ---
 
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
+ description: This is text-to-image model (stable-diffusion-v1-5) running locally on your machine(mac apple silicon) with a Gradio UI
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Provide the url to model id
2
+ url = "runwayml/stable-diffusion-v1-5"
3
+
4
+ # Load the safetensor model
5
+ pipe = DiffusionPipeline.from_pretrained(model_file_path, use_safetensors=True )
6
+ pipe = pipe.to("mps")
7
+
8
+ def predict(text):
9
+ # Ensure pipe(text) returns the correct output format
10
+ generated_image = pipe(text).images[0]
11
+ return generated_image
12
+
13
+
14
+
15
+ iface = gr.Interface(
16
+ fn=predict,
17
+ inputs='text',
18
+ outputs='image',
19
+ )
20
+
21
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ accelerate==0.29.2
2
+ aiofiles==23.2.1
3
+ altair==5.3.0
4
+ annotated-types==0.6.0
5
+ anyio==4.3.0
6
+ attrs==23.2.0
7
+ certifi==2024.2.2
8
+ charset-normalizer==3.3.2
9
+ click==8.1.7
10
+ contourpy==1.2.1
11
+ cycler==0.12.1
12
+ diffusers @ git+https://github.com/huggingface/diffusers@08bf7545070764d41637e90290ca9b92b392263e
13
+ fastapi==0.110.1
14
+ ffmpy==0.3.2
15
+ filelock==3.13.4
16
+ fonttools==4.51.0
17
+ fsspec==2024.3.1
18
+ gradio==4.26.0
19
+ gradio_client==0.15.1
20
+ h11==0.14.0
21
+ httpcore==1.0.5
22
+ httpx==0.27.0
23
+ huggingface-hub==0.22.2
24
+ idna==3.7
25
+ importlib_metadata==7.1.0
26
+ importlib_resources==6.4.0
27
+ Jinja2==3.1.3
28
+ jsonschema==4.21.1
29
+ jsonschema-specifications==2023.12.1
30
+ kiwisolver==1.4.5
31
+ markdown-it-py==3.0.0
32
+ MarkupSafe==2.1.5
33
+ matplotlib==3.8.4
34
+ mdurl==0.1.2
35
+ mpmath==1.3.0
36
+ networkx==3.3
37
+ numpy==1.26.4
38
+ orjson==3.10.0
39
+ packaging==24.0
40
+ pandas==2.2.2
41
+ pillow==10.3.0
42
+ psutil==5.9.8
43
+ pydantic==2.7.0
44
+ pydantic_core==2.18.1
45
+ pydub==0.25.1
46
+ Pygments==2.17.2
47
+ pyparsing==3.1.2
48
+ python-dateutil==2.9.0.post0
49
+ python-multipart==0.0.9
50
+ pytz==2024.1
51
+ PyYAML==6.0.1
52
+ referencing==0.34.0
53
+ regex==2023.12.25
54
+ requests==2.31.0
55
+ rich==13.7.1
56
+ rpds-py==0.18.0
57
+ ruff==0.3.7
58
+ safetensors==0.4.2
59
+ semantic-version==2.10.0
60
+ shellingham==1.5.4
61
+ six==1.16.0
62
+ sniffio==1.3.1
63
+ starlette==0.37.2
64
+ sympy==1.12
65
+ tokenizers==0.15.2
66
+ tomlkit==0.12.0
67
+ toolz==0.12.1
68
+ torch==2.2.2
69
+ torchvision==0.17.2
70
+ tqdm==4.66.2
71
+ transformers==4.39.3
72
+ typer==0.12.3
73
+ typing_extensions==4.11.0
74
+ tzdata==2024.1
75
+ urllib3==2.2.1
76
+ uvicorn==0.29.0
77
+ websockets==11.0.3
78
+ zipp==3.18.1