rajesh1729 commited on
Commit
7671896
1 Parent(s): c241d6a

Delete gan1.ipynb

Browse files
Files changed (1) hide show
  1. gan1.ipynb +0 -141
gan1.ipynb DELETED
@@ -1,141 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "raw",
5
- "id": "c6be22eb",
6
- "metadata": {},
7
- "source": [
8
- "---\n",
9
- "title: Toonify your Pics\n",
10
- "description: Creates a cartoon version of your pic(with download option)\n",
11
- "show-code: False\n",
12
- "params:\n",
13
- " image_path:\n",
14
- " input: file\n",
15
- " label: Please upload a photo\n",
16
- " output_dir:\n",
17
- " output: dir\n",
18
- "---"
19
- ]
20
- },
21
- {
22
- "cell_type": "markdown",
23
- "id": "a6b9cb66",
24
- "metadata": {},
25
- "source": [
26
- "## Open In colab Badge"
27
- ]
28
- },
29
- {
30
- "cell_type": "code",
31
- "execution_count": null,
32
- "id": "c4481a3c",
33
- "metadata": {},
34
- "outputs": [],
35
- "source": [
36
- "image_path = 'trump.jpg'\n",
37
- "output_dir = \"output_images\""
38
- ]
39
- },
40
- {
41
- "cell_type": "code",
42
- "execution_count": null,
43
- "id": "a8803760",
44
- "metadata": {},
45
- "outputs": [],
46
- "source": [
47
- "import os\n",
48
- "import torch\n",
49
- "from PIL import Image\n",
50
- "import warnings\n",
51
- "warnings.filterwarnings(\"ignore\")"
52
- ]
53
- },
54
- {
55
- "cell_type": "markdown",
56
- "id": "56e86849",
57
- "metadata": {},
58
- "source": [
59
- "## This is the Toonify app that creates a cartoon version of any image you upload. \n",
60
- "## Upload an image by clicking the 'Browse' button or by 'Drag & Drop' and click 'Run' to toonify your image.\n"
61
- ]
62
- },
63
- {
64
- "cell_type": "code",
65
- "execution_count": null,
66
- "id": "ddb89e68",
67
- "metadata": {},
68
- "outputs": [],
69
- "source": [
70
- "model = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"generator\", pretrained=\"paprika\")\n",
71
- "face2paint = torch.hub.load(\"bryandlee/animegan2-pytorch:main\", \"face2paint\", size=512)"
72
- ]
73
- },
74
- {
75
- "cell_type": "code",
76
- "execution_count": null,
77
- "id": "43dccffa",
78
- "metadata": {},
79
- "outputs": [],
80
- "source": [
81
- "def toonify(img):\n",
82
- " out = face2paint(model, img)\n",
83
- " return out"
84
- ]
85
- },
86
- {
87
- "cell_type": "code",
88
- "execution_count": null,
89
- "id": "71e9255d",
90
- "metadata": {},
91
- "outputs": [],
92
- "source": [
93
- "im = Image.open(image_path).convert('RGB')"
94
- ]
95
- },
96
- {
97
- "cell_type": "code",
98
- "execution_count": null,
99
- "id": "a31f4c2c",
100
- "metadata": {
101
- "scrolled": false
102
- },
103
- "outputs": [],
104
- "source": [
105
- "toonify(im)"
106
- ]
107
- },
108
- {
109
- "cell_type": "code",
110
- "execution_count": null,
111
- "id": "33c1461a",
112
- "metadata": {},
113
- "outputs": [],
114
- "source": [
115
- "#toonify(im).save(f\"{output_dir}/toonify.jpg\")\n",
116
- "#print(\"To download your toonified image, click the output files option at the top and click download\")"
117
- ]
118
- }
119
- ],
120
- "metadata": {
121
- "kernelspec": {
122
- "display_name": "Python 3 (ipykernel)",
123
- "language": "python",
124
- "name": "python3"
125
- },
126
- "language_info": {
127
- "codemirror_mode": {
128
- "name": "ipython",
129
- "version": 3
130
- },
131
- "file_extension": ".py",
132
- "mimetype": "text/x-python",
133
- "name": "python",
134
- "nbconvert_exporter": "python",
135
- "pygments_lexer": "ipython3",
136
- "version": "3.8.13"
137
- }
138
- },
139
- "nbformat": 4,
140
- "nbformat_minor": 5
141
- }