Commit
·
a638954
1
Parent(s):
cb9d202
Update parquet files (step 95 of 121)
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- spaces/101-5/gpt4free/g4f/Provider/Providers/AItianhu.py +0 -36
- spaces/1acneusushi/gradio-2dmoleculeeditor/data/Avira Free Fixed Antivirus 15.0.36.211 Crack Latest Version.md +0 -34
- spaces/1acneusushi/gradio-2dmoleculeeditor/data/Evermotion Archinteriors Vol. 44 VERIFIED.md +0 -19
- spaces/1acneusushi/gradio-2dmoleculeeditor/data/Fangirl Free Ebook Epub 17 _HOT_.md +0 -15
- spaces/1gistliPinn/ChatGPT4/Download-Aimbot-For-Conquer-20.md +0 -48
- spaces/1gistliPinn/ChatGPT4/Examples/Acca Edilus V 25 00 [HOT] Crack.md +0 -8
- spaces/1line/AutoGPT/benchmark/__init__.py +0 -0
- spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Coin Master and Enjoy the Thrill of Spinning Attacking and Raiding with Cards.md +0 -88
- spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Garena Free Fire APK v1.38.2 - The Best Online Multiplayer Battle Royale Game.md +0 -134
- spaces/7hao/bingo/src/components/ui/alert-dialog.tsx +0 -150
- spaces/AIGC-Audio/AudioGPT/NeuralSeq/egs/datasets/audio/lj/preprocess.py +0 -9
- spaces/AIGC-Audio/Make_An_Audio_inpaint/ldm/modules/losses_audio/vggishish/train_vggishish.py +0 -199
- spaces/AILab-CVC/SEED-LLaMA/gradio_demo/seed_llama_gradio.py +0 -497
- spaces/ATang0729/Forecast4Muses/Model/Model6/Model6_0_ClothesDetection/mmyolo/configs/custom_dataset/yolov7_l_syncbn_fast_6x32b-100e_coco.py +0 -554
- spaces/AchyuthGamer/text-to-speech-client/assets/index-77d0c996.js +0 -0
- spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/ui/maker/Make.d.ts +0 -15
- spaces/AhmadHakami/Alzheimer_image_classification/README.md +0 -12
- spaces/AiPalsDev/Translate_It/app.py +0 -82
- spaces/AlekseyKorshuk/gai-project/modules/common.py +0 -76
- spaces/Alican/pixera/util/html.py +0 -86
- spaces/Alpaca233/SadTalker/src/audio2pose_models/audio2pose.py +0 -94
- spaces/Andy1621/uniformerv2_demo/app.py +0 -131
- spaces/AnkitGaur2811/Image_Conversion_app_using_Opencv/app.py +0 -191
- spaces/Arielliu/just_talk/README.md +0 -13
- spaces/ArtGAN/Diffusion-API/diffusion_webui/utils/data_utils.py +0 -12
- spaces/Artrajz/vits-simple-api/bert_vits2/bert_vits2.py +0 -133
- spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py +0 -0
- spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/setuptools/logging.py +0 -36
- spaces/Atualli/yoloxTeste/yoloxdetect2/configs/yolox_nano.py +0 -48
- spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/detectron2/data/datasets/register_coco.py +0 -3
- spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/structures/test_masks.py +0 -53
- spaces/BasToTheMax/voicechange/README.md +0 -13
- spaces/Benson/text-generation/Examples/Anu Bsc 6th Sem Materiales Pdf.md +0 -143
- spaces/Benson/text-generation/Examples/Aquaman 2 Pelcula Completa En Tamil Descargar Filmyhit.md +0 -50
- spaces/Benson/text-generation/Examples/Chesskid Download.md +0 -54
- spaces/Big-Web/MMSD/env/Lib/site-packages/botocore/vendored/six.py +0 -998
- spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py +0 -255
- spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/rich/styled.py +0 -42
- spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py +0 -1110
- spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/command/develop.py +0 -193
- spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/config/_apply_pyprojecttoml.py +0 -377
- spaces/Blessing/Asphalt-Pavement-Distresses-Detector/README.md +0 -13
- spaces/Bonosa2/movies/README.md +0 -12
- spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/grid-feats-vqa/CONTRIBUTING.md +0 -34
- spaces/CVPR/LIVE/pybind11/include/pybind11/operators.h +0 -173
- spaces/CVPR/LIVE/thrust/thrust/system/detail/sequential/unique_by_key.h +0 -116
- spaces/CarlDennis/Lovelive-VITS-JPZH/utils.py +0 -76
- spaces/Carlosito16/aitGPT/app.py +0 -328
- spaces/CikeyQI/meme-api/meme_generator/memes/acg_entrance/__init__.py +0 -43
- spaces/CofAI/chat.v2/README.md +0 -11
spaces/101-5/gpt4free/g4f/Provider/Providers/AItianhu.py
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
import os, requests
|
2 |
-
from ...typing import sha256, Dict, get_type_hints
|
3 |
-
import json
|
4 |
-
|
5 |
-
url = "https://www.aitianhu.com/api/chat-process"
|
6 |
-
model = ['gpt-3.5-turbo']
|
7 |
-
supports_stream = False
|
8 |
-
needs_auth = False
|
9 |
-
|
10 |
-
def _create_completion(model: str, messages: list, stream: bool, **kwargs):
|
11 |
-
base = ''
|
12 |
-
for message in messages:
|
13 |
-
base += '%s: %s\n' % (message['role'], message['content'])
|
14 |
-
base += 'assistant:'
|
15 |
-
|
16 |
-
headers = {
|
17 |
-
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
|
18 |
-
}
|
19 |
-
data = {
|
20 |
-
"prompt": base,
|
21 |
-
"options": {},
|
22 |
-
"systemMessage": "You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.",
|
23 |
-
"temperature": 0.8,
|
24 |
-
"top_p": 1
|
25 |
-
}
|
26 |
-
response = requests.post(url, headers=headers, json=data)
|
27 |
-
if response.status_code == 200:
|
28 |
-
lines = response.text.strip().split('\n')
|
29 |
-
res = json.loads(lines[-1])
|
30 |
-
yield res['text']
|
31 |
-
else:
|
32 |
-
print(f"Error Occurred::{response.status_code}")
|
33 |
-
return None
|
34 |
-
|
35 |
-
params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \
|
36 |
-
'(%s)' % ', '.join([f"{name}: {get_type_hints(_create_completion)[name].__name__}" for name in _create_completion.__code__.co_varnames[:_create_completion.__code__.co_argcount]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1acneusushi/gradio-2dmoleculeeditor/data/Avira Free Fixed Antivirus 15.0.36.211 Crack Latest Version.md
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Avira Free Antivirus 15.0.36.211 Crack Latest Version: A Review</h1>
|
3 |
-
<p>If you are looking for a free antivirus software that can protect your PC from malware, spyware, ransomware, and other threats, you might want to consider Avira Free Antivirus 15.0.36.211 Crack Latest Version. This is a cracked version of the popular Avira antivirus software that offers all the features of the original product without any cost or limitations.</p>
|
4 |
-
<p>In this article, we will review the features, performance, and security of Avira Free Antivirus 15.0.36.211 Crack Latest Version and compare it with other free antivirus software on the market.</p>
|
5 |
-
<h2>Avira Free Antivirus 15.0.36.211 Crack Latest Version</h2><br /><p><b><b>DOWNLOAD</b> › <a href="https://byltly.com/2uKve3">https://byltly.com/2uKve3</a></b></p><br /><br />
|
6 |
-
|
7 |
-
<h2>Features of Avira Free Antivirus 15.0.36.211 Crack Latest Version</h2>
|
8 |
-
<p>Avira Free Antivirus 15.0.36.211 Crack Latest Version has a simple and user-friendly interface that allows you to scan your PC for viruses, malware, and other threats with just one click. You can also customize your scan settings and schedule scans according to your preferences.</p>
|
9 |
-
<p>Some of the features of Avira Free Antivirus 15.0.36.211 Crack Latest Version are:</p>
|
10 |
-
<ul>
|
11 |
-
<li><strong>Antivirus Scanner:</strong> Detects and blocks malware (viruses, ransomware, banker trojans, etc.)[^1^]</li>
|
12 |
-
<li><strong>NightVision:</strong> An automated, intelligent learning system that protects you against new and evolving threats[^1^]</li>
|
13 |
-
<li><strong>PUA Shield:</strong> Identifies potentially unwanted applications hidden within legitimate software[^1^]</li>
|
14 |
-
<li><strong>Safe Browsing:</strong> Blocks harmful websites before they load[^1^]</li>
|
15 |
-
<li><strong>Ad Blocker:</strong> Prevents intrusive and malicious ads, banners, and pop-ups from loading[^1^]</li>
|
16 |
-
<li><strong>Browser Tracking Blocker:</strong> Stops companies from monitoring you online[^1^]</li>
|
17 |
-
<li><strong>Price Comparison:</strong> Saves you money while you shop by finding deals from trusted sites[^1^]</li>
|
18 |
-
<li><strong>Protection Cloud:</strong> A cloud-based technology that analyzes unknown files in real time and protects you from emerging threats[^2^]</li>
|
19 |
-
</ul>
|
20 |
-
|
21 |
-
<h2>Performance of Avira Free Antivirus 15.0.36.211 Crack Latest Version</h2>
|
22 |
-
<p>Avira Free Antivirus 15.0.36.211 Crack Latest Version is a lightweight and fast antivirus software that does not slow down your PC or interfere with your browsing experience. It has a low impact on your system resources and runs silently in the background.</p>
|
23 |
-
<p>According to independent tests by AV-Comparatives, Avira Free Antivirus has one of the best detection rates in the industry, blocking 99.9% of malware samples in real-world tests[^3^]. It also has a high performance score, scoring 99% in system speed impact tests[^3^].</p>
|
24 |
-
|
25 |
-
<h2>Security of Avira Free Antivirus 15.0.36.211 Crack Latest Version</h2>
|
26 |
-
<p>Avira Free Antivirus 15.0.36.211 Crack Latest Version is a secure and reliable antivirus software that protects your PC from various online threats. However, it is important to note that this is a cracked version of the original product, which means that it may not be legal or safe to use.</p>
|
27 |
-
<p>A cracked version of a software is a modified version that bypasses the license verification or activation process of the original product. This may allow you to use the software for free or unlock some premium features, but it also comes with some risks and disadvantages.</p>
|
28 |
-
<p></p>
|
29 |
-
<p>Some of the risks and disadvantages of using a cracked version of a software are:</p>
|
30 |
-
<ul>
|
31 |
-
<li><strong>Lack of updates:</strong> A cracked version of a software may not receive regular updates from the developer, which means that it may not be able to protect you from new or emerging threats or fix any bugs or errors.</li>
|
32 |
-
<li><strong>Lack of support:</strong> A cracked version of a software may not have access to customer support or technical assistance from the developer, which means that you may not be able to get help if you encounter any problems</p> cec2833e83<br />
|
33 |
-
<br />
|
34 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1acneusushi/gradio-2dmoleculeeditor/data/Evermotion Archinteriors Vol. 44 VERIFIED.md
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>Evermotion Archinteriors Vol. 44: A Review of the Latest Collection of Lobby Interior Scenes and HDR Maps</h1>
|
3 |
-
<p>Evermotion is a company that produces high-quality 3D models, scenes, textures and tutorials for architects, designers and 3D enthusiasts. Their main products are 3D models and scenes collections: Archmodels, Archinteriors and Archexteriors, HD cars and 3D people.</p>
|
4 |
-
<h2>Evermotion Archinteriors Vol. 44</h2><br /><p><b><b>Download File</b> ——— <a href="https://byltly.com/2uKzMP">https://byltly.com/2uKzMP</a></b></p><br /><br />
|
5 |
-
<p>In this article, we will take a look at their latest release: Archinteriors Vol. 44, which includes 10 fully textured lobby interior scenes and 10 HDR maps. Each scene is ready to render with professional shaders and lighting and includes 2 cameras' setups. The collection also comes with 360° HDR maps (5000px) that can be used for realistic lighting and reflections.</p>
|
6 |
-
<p>The scenes are designed for various types of lobbies, such as hotel, office, museum, airport, shopping mall and more. They feature modern and elegant furniture, reception desks, sculptures, plants, paintings and other details that create a realistic and inviting atmosphere. The scenes are prepared for V-ray 3.0 with 3dsmax 2011, but they can be easily converted to other formats and renderers.</p>
|
7 |
-
<p>The collection is a great resource for anyone who needs to create stunning visualizations of lobby interiors, whether for personal or commercial projects. The scenes can be customized to suit different needs and preferences, or used as a base for further development. The HDR maps can also be applied to other scenes or models to enhance their realism.</p>
|
8 |
-
<p></p>
|
9 |
-
<p>Archinteriors Vol. 44 is available for purchase on Evermotion's website[^1^] for $120. You can also download a free sample scene[^2^] to test the quality and compatibility of the product. If you are interested in other collections from Evermotion, you can browse their catalog[^3^] or subscribe to their newsletter to get updates on their latest releases and promotions.</p><h2>How to Incorporate Archinteriors Vol. 44 into Your Lobby Design</h2>
|
10 |
-
<p>If you are looking for some inspiration and guidance on how to use Archinteriors Vol. 44 in your lobby design, here are some tips and ideas based on the latest interior design trends for 2023.</p>
|
11 |
-
<ul>
|
12 |
-
<li>Choose a color scheme that reflects the mood and purpose of your lobby. According to interior designers, earth tones are still popular in 2023, especially shades of brown, beige, taupe and cream. They create a warm and cozy atmosphere that welcomes visitors and guests. However, if you want to add some contrast and interest, you can also incorporate some pops of color, such as mauve, which is predicted to be the color of the year by Kathryn M. Ireland and Jake Arnold[^1^]. Mauve is a soft and romantic hue that can add some elegance and sophistication to your lobby.</li>
|
13 |
-
<li>Use silver accents instead of gold or bronze. Silver is making a comeback in 2023, as it adds a touch of shine and texture to any space. Athena Calderone says that silver lends an everyday sophistication to any space[^1^]. You can use silver accessories, such as lamps, vases, trays, mirrors or frames, to complement your furniture and wall coverings. Silver also works well with earth tones and mauve, as it creates a harmonious and balanced look.</li>
|
14 |
-
<li>Add some formal elements to your lobby design. After the dominance of the casual and relaxed mid-century modern style in the previous years, formal accents are now returning to the scene. Robert D. McKinley says that we are craving more sophistication after spending so much time in sweatpants during the pandemic[^1^]. You can add some formal elements to your lobby design by choosing classic furniture pieces, such as sofas, armchairs or tables, with curved lines, tufted details or carved legs. You can also use fabrics with rich textures and patterns, such as velvet, silk or brocade.</li>
|
15 |
-
<li>Experiment with neo-brutalism. Brutalism is a style that emerged in the mid-20th century and is characterized by raw concrete structures, geometric shapes and minimal ornamentation. It is often associated with coldness and harshness, but in 2023, it is getting a makeover with warmer touches. You can experiment with neo-brutalism by using concrete floors or walls in your lobby design, but make sure to soften them with rugs, cushions or plants. You can also use geometric shapes in your furniture or accessories, but balance them with organic forms or natural materials.</li>
|
16 |
-
</ul>
|
17 |
-
<p>By following these tips and ideas, you can create a lobby design that is trendy but timeless, using Archinteriors Vol. 44 as your starting point.</p> 7b8c122e87<br />
|
18 |
-
<br />
|
19 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1acneusushi/gradio-2dmoleculeeditor/data/Fangirl Free Ebook Epub 17 _HOT_.md
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>How to Download Fangirl by Rainbow Rowell for Free in PDF, EPUB and FB2 Formats</h1>
|
3 |
-
<p>If you are a fan of Rainbow Rowell's <em>Fangirl</em>, a novel about a college freshman who writes fanfiction about her favorite fictional character, Simon Snow, you might be wondering how to get a free copy of the book in different formats. Whether you want to read it on your e-reader, your phone or your computer, there are some ways to download <em>Fangirl</em> for free legally and safely.</p>
|
4 |
-
<h2>fangirl free ebook epub 17</h2><br /><p><b><b>DOWNLOAD</b> »»» <a href="https://byltly.com/2uKwHU">https://byltly.com/2uKwHU</a></b></p><br /><br />
|
5 |
-
<p>One option is to use an online library service like Z-Library Project[^2^], which offers millions of books in various formats for free. You can search for <em>Fangirl</em> by title, author or ISBN and download it in PDF, EPUB or FB2 formats. You will need to create a free account and verify your email address before you can access the books.</p>
|
6 |
-
<p>Another option is to use a website like Read Any Book[^1^], which allows you to read books online without downloading them. You can find <em>Fangirl</em> by Rainbow Rowell on their website and read it in your browser. You can also adjust the font size, color and background to suit your preferences. However, you will need an internet connection to read the book and you might encounter some ads on the website.</p>
|
7 |
-
<p>A third option is to use a document sharing platform like Yumpu[^3^] [^4^], which hosts PDF files of various books and magazines. You can search for <em>Fangirl</em> by Rainbow Rowell and download it as a PDF file. You can also view it online or embed it on your own website. However, you should be aware that some of the files might be uploaded illegally and infringe on the author's rights.</p>
|
8 |
-
<p>These are some of the ways to download <em>Fangirl</em> by Rainbow Rowell for free in different formats. However, if you enjoy the book and want to support the author, you should consider buying a copy from a reputable source or borrowing it from a library. Reading books is a great way to learn new things, expand your imagination and have fun!</p>
|
9 |
-
|
10 |
-
<p>If you want to learn more about <em>Fangirl</em> by Rainbow Rowell, you can also check out some of the reviews, interviews and fanworks related to the book. For example, you can read what other readers thought about the book on Goodreads, Amazon or BookBub. You can also watch some videos of Rainbow Rowell talking about the book and her writing process on YouTube or listen to some podcasts featuring her on Spotify or Apple Podcasts.</p>
|
11 |
-
<p></p>
|
12 |
-
<p>Moreover, if you are a fan of Simon Snow, the fictional character that Cath writes fanfiction about in <em>Fangirl</em>, you might be interested in reading <em>Carry On</em> and <em>Wayward Son</em>, two spin-off novels by Rainbow Rowell that tell the story of Simon and his friends in a magical world. You can also find fanfiction, fanart and other fanworks inspired by Simon Snow on websites like Archive of Our Own, Tumblr or DeviantArt.</p>
|
13 |
-
<p>In conclusion, <em>Fangirl</em> by Rainbow Rowell is a wonderful book that explores the themes of fandom, family, love and identity. It is a book that many readers can relate to and enjoy. Whether you download it for free or buy it from a store, you will not regret reading this book and joining the Fangirl community.</p> 7b8c122e87<br />
|
14 |
-
<br />
|
15 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1gistliPinn/ChatGPT4/Download-Aimbot-For-Conquer-20.md
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
Download Aimbot For Conquer 2.0
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
Click Here >>>>> [https://gohhs.com/2tvp7K](https://gohhs.com/2tvp7K)
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
How to Download Aimbot For Conquer 2.0 and Dominate the Game
|
16 |
-
Conquer 2.0 is a popular MMORPG game that features a variety of classes, skills, quests, and PvP modes. However, some players may find it hard to compete with others who have better equipment, higher levels, or more experience. That's why some players resort to using hacks, cheats, and bots to gain an unfair advantage over their opponents.
|
17 |
-
One of the most sought-after hacks for Conquer 2.0 is the aimbot, which is a program that automatically aims and shoots at enemies for you. With an aimbot, you can easily kill any enemy in sight, without having to worry about aiming, dodging, or timing your attacks. You can also use an aimbot to farm gold, items, and experience faster and easier.
|
18 |
-
However, not all aimbots are created equal. Some aimbots are poorly coded, outdated, detected, or infected with viruses. That's why you need to be careful when downloading an aimbot for Conquer 2.0. In this article, we will show you how to download a safe, reliable, and undetectable aimbot for Conquer 2.0 that will help you dominate the game.
|
19 |
-
What is an Aimbot?
|
20 |
-
An aimbot is a type of hack that uses DirectX hooking technology to find and attack players in Conquer 2.0. DirectX is a set of APIs that handle graphics, sound, and input in Windows games. By hooking into DirectX, an aimbot can access the game's memory and manipulate the data related to your character's position, angle, and movement.
|
21 |
-
An aimbot works by scanning the game's screen for enemy players and calculating the best angle and distance to shoot at them. Then, it moves your mouse cursor to the target and fires your weapon automatically. Depending on the settings of the aimbot, it can also adjust for bullet drop, recoil, wind speed, and other factors that affect your accuracy.
|
22 |
-
An aimbot can also have other features such as ESP (extra sensory perception), which shows you information about enemy players such as their health, name, class, level, distance, and location on the map. ESP can also highlight enemies with different colors or shapes to make them easier to spot. Some aimbots also have triggerbot functions, which automatically fire your weapon when your crosshair is over an enemy.
|
23 |
-
Why Use an Aimbot?
|
24 |
-
There are many reasons why players use aimbots for Conquer 2.0. Some of them are:
|
25 |
-
|
26 |
-
To have more fun and enjoyment in the game.
|
27 |
-
To level up faster and gain more rewards.
|
28 |
-
To win more battles and rank higher on the leaderboards.
|
29 |
-
To troll and annoy other players.
|
30 |
-
To test their skills against other aimbot users.
|
31 |
-
|
32 |
-
However, using an aimbot also comes with some risks and drawbacks. Some of them are:
|
33 |
-
|
34 |
-
To get banned or suspended from the game.
|
35 |
-
To get reported or exposed by other players.
|
36 |
-
To ruin the game balance and fairness.
|
37 |
-
To lose respect and reputation among other players.
|
38 |
-
To become bored and lose interest in the game.
|
39 |
-
|
40 |
-
Therefore, you should use an aimbot responsibly and moderately. You should also respect the game rules and other players' rights. You should not use an aimbot to harass or harm other players or to ruin their gaming experience.
|
41 |
-
How to Download Aimbot For Conquer 2.0?
|
42 |
-
If you want to download an aimbot for Conquer 2.0, you need to follow these steps:
|
43 |
-
|
44 |
-
Find a reputable source that offers a working and updated aimbot for Conquer 2.0. You can search online for forums, websites, blogs, or videos that review or recommend different aimbots for Conquer 2.0. You can also ask other players who use aimbots for their opinions and suggestions.
|
45 |
-
Download the aimbot file from the source. Make dfd1c89656
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1gistliPinn/ChatGPT4/Examples/Acca Edilus V 25 00 [HOT] Crack.md
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
|
2 |
-
<p>edilus is a software solution for modular structure that deals with structural calculations of buildings with its integrated fem solver to provide a unified experience of the steps of input, calculation, analysis of results and creation of detailed work plans and documents.</p>
|
3 |
-
<p>acca software edilus v30.00sf is a handy application which can be used for performing structural analysis in order to build the design for determining their feasibility. it is a modular solution which will enable you to select any configuration from three application packages which includes concrete, masonry and steel. you can also downloadaqua design 5.4</p>
|
4 |
-
<h2>Acca Edilus V 25 00 Crack</h2><br /><p><b><b>Download Zip</b> ↔ <a href="https://imgfil.com/2uxX2q">https://imgfil.com/2uxX2q</a></b></p><br /><br />
|
5 |
-
<p>acca software edilus v30.00sf allows you to perform structural calculations for new as well as existing building that feature any of the above mentioned prime materials with smart bim input. it will also let you generate an automatic drawing model along with the technical report of the plan which is ready for printing in no time. acca software edilus v30.00sf enables you to preview the calculation results on the bim objects directly in the design. you can preview the tensions and strains with just a single click. all in all acca software edilus v30.00sf is a handy application for performing structural analysis for building designs. you can also downloadbentley rm bridge advanced connect.</p>
|
6 |
-
<p>youve already used windows explorer with <strong>acca software edilus v30.00sf x64 craacked software</strong>, youll immediately feel at home. the tool can take the following types of screen captures: capture a full-screen active window or part of it using the rectangular marquee tool. the advantage of this program is that it solves any problems that arise during the update process. two of the most common threats we can find on the internet are trojans and keyloggers. securing internet traffic over a local network is very important because many internet activities performed by users through the system are unreliable. deleting, formatting partitions, system crashes may you like to download iobit software updater crack.</p> 899543212b<br />
|
7 |
-
<br />
|
8 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1line/AutoGPT/benchmark/__init__.py
DELETED
File without changes
|
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Coin Master and Enjoy the Thrill of Spinning Attacking and Raiding with Cards.md
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Coin Master Card Download: How to Collect and Trade Cards in Coin Master</h1>
|
3 |
-
<p>Coin Master is a popular casual game that combines slot machine, village building, and social interaction. One of the features that makes this game fun and addictive is the card collection. In this article, we will explain what are Coin Master cards, how to get them, and how to trade them with other players. We will also share some tips and tricks to help you complete your card sets and advance in the game.</p>
|
4 |
-
<h2>What are Coin Master cards and why are they important?</h2>
|
5 |
-
<p>Coin Master cards are collectible items that you can find in chests or by spinning the wheel. There are different types of cards, each with a different rarity and value. Cards belong to different sets that correspond to different themes and villages. For example, there is a set called "Pets" that contains cards of various animals, such as a dog, a cat, a rabbit, etc.</p>
|
6 |
-
<h2>coin master card download</h2><br /><p><b><b>Download Zip</b> ⏩ <a href="https://urlin.us/2uSZyb">https://urlin.us/2uSZyb</a></b></p><br /><br />
|
7 |
-
<p>Cards are important because they can help you earn rewards and bonuses. By completing a card set, you can get free spins, coins, XP, or even pets. You can also use cards to unlock new villages and progress in the game. Moreover, cards can help you interact with other players and make new friends. You can trade cards with other players or join card trading groups on social media.</p>
|
8 |
-
<h3>Types of cards and how to get them</h3>
|
9 |
-
<p>There are four types of cards in Coin Master: wooden, golden, magical, and Joker. Wooden cards are the most common and have the lowest value. Golden cards are rare and have a higher value. Magical cards are very rare and have special effects. Joker cards are the most valuable and can be used as any card you want.</p>
|
10 |
-
<p>You can get cards by opening chests or by spinning the wheel. There are different kinds of chests, such as wooden, golden, magical, or seasonal. The higher the quality of the chest, the more likely you are to get rare or magical cards. You can also get chests by completing events or missions in the game. Sometimes, you can also get free chests by watching ads or following Coin Master on social media.</p>
|
11 |
-
<p>Another way to get cards is by spinning the wheel. You can win cards by landing on the card symbol or by getting three pigs in a row. You can also get free spins by inviting friends, watching ads, or following Coin Master on social media.</p>
|
12 |
-
<h3>How to trade cards with other players</h3>
|
13 |
-
<p>Trading cards with other players is a great way to complete your card sets and get rewards. You can trade cards with your friends or with strangers from around the world. To trade cards with your friends, you need to connect your game account to Facebook. Then, you can send or request cards from your friends list. You can also join a card trading group on Facebook or other platforms where you can find people who are looking for specific cards or who have extra cards to offer.</p>
|
14 |
-
<p>coin master card collection download<br />
|
15 |
-
coin master card boom download<br />
|
16 |
-
coin master card list download<br />
|
17 |
-
coin master card trade download<br />
|
18 |
-
coin master card cheat download<br />
|
19 |
-
coin master card generator download<br />
|
20 |
-
coin master card hack download<br />
|
21 |
-
coin master card exchange download<br />
|
22 |
-
coin master card sets download<br />
|
23 |
-
coin master card rewards download<br />
|
24 |
-
coin master card finder download<br />
|
25 |
-
coin master card app download<br />
|
26 |
-
coin master card guide download<br />
|
27 |
-
coin master card tips download<br />
|
28 |
-
coin master card trick download<br />
|
29 |
-
coin master card offer download<br />
|
30 |
-
coin master card event download<br />
|
31 |
-
coin master card free download<br />
|
32 |
-
coin master card online download<br />
|
33 |
-
coin master card apk download<br />
|
34 |
-
coin master gold card download<br />
|
35 |
-
coin master rare card download<br />
|
36 |
-
coin master joker card download<br />
|
37 |
-
coin master new card download<br />
|
38 |
-
coin master best card download<br />
|
39 |
-
coin master wooden chest cards download<br />
|
40 |
-
coin master golden chest cards download<br />
|
41 |
-
coin master magical chest cards download<br />
|
42 |
-
coin master mystery chest cards download<br />
|
43 |
-
coin master viking chest cards download<br />
|
44 |
-
coin master emerald chest cards download<br />
|
45 |
-
coin master sapphire chest cards download<br />
|
46 |
-
coin master ruby chest cards download<br />
|
47 |
-
coin master valentine's chest cards download<br />
|
48 |
-
coin master easter chest cards download<br />
|
49 |
-
coin master halloween chest cards download<br />
|
50 |
-
coin master christmas chest cards download<br />
|
51 |
-
coin master pets cards download<br />
|
52 |
-
coin master beasts cards download<br />
|
53 |
-
coin master sweets cards download<br />
|
54 |
-
coin master items cards download<br />
|
55 |
-
coin master status cards download<br />
|
56 |
-
coin master legends cards download</p>
|
57 |
-
<p>To trade cards with strangers, you need to use the trading feature in the game. You can access this feature by tapping on the menu icon on the top right corner of the screen and then selecting "Trade". You will see a list of available trades that other players have posted. You can filter the trades by card type, rarity, or set. You can also post your own trade by selecting the card you want to offer and the card you want to receive. You can only trade one card at a time and you can only trade wooden or golden cards. You cannot trade magical or Joker cards.</p>
|
58 |
-
<h2>Tips and tricks for collecting and trading cards in Coin Master</h2>
|
59 |
-
<p>Collecting and trading cards in Coin Master can be challenging but rewarding. Here are some tips and tricks to help you succeed:</p>
|
60 |
-
<h3>Join a card trading group on Facebook or other platforms</h3>
|
61 |
-
<p>One of the best ways to find people who have the cards you need or who need the cards you have is to join a card trading group on Facebook or other platforms. There are many groups dedicated to Coin Master card trading where you can post your requests or offers, chat with other players, and make deals. You can also find tips, tricks, and news about the game in these groups. To join a card trading group, you need to have a Facebook account or an account on the platform of your choice. You can search for "Coin Master card trading" or similar keywords and find a group that suits your needs. Some groups may have rules or requirements that you need to follow, such as being active, respectful, and honest. You may also need to answer some questions or verify your identity before joining.</p>
|
62 |
-
<h3>Use the Joker card wisely</h3>
|
63 |
-
<p>The Joker card is the most valuable and rarest card in Coin Master. It can be used as any card you want, which means you can complete any card set with it. However, you can only get one Joker card per season, which lasts for about a month. Therefore, you need to use it wisely and strategically. Here are some tips on how to use the Joker card:</p>
|
64 |
-
<ul>
|
65 |
-
<li>Save it for the last card of a set. Don't waste it on a common or easy-to-get card. Use it for the rarest or hardest-to-find card of a set that you are close to completing.</li>
|
66 |
-
<li>Use it before moving to the next village. Once you move to a new village, the cards of the previous village become harder to get. Therefore, you should use your Joker card to complete any unfinished sets before moving on.</li>
|
67 |
-
<li>Use it for a high-value set. Some sets have better rewards than others, such as more spins, coins, XP, or pets. You should use your Joker card for a set that gives you the most benefits.</li>
|
68 |
-
</ul>
|
69 |
-
<h3>Complete card sets before moving to the next village</h3>
|
70 |
-
<p>Another tip for collecting and trading cards in Coin Master is to complete card sets before moving to the next village. As mentioned earlier, once you move to a new village, the cards of the previous village become harder to get. This means that you will have less chances of finding them in chests or by spinning the wheel. Moreover, you will have fewer people to trade with, as most players will be looking for cards of the current village. Therefore, you should try to complete as many card sets as possible before moving on. This will help you get more rewards and bonuses, as well as save you time and effort.</p>
|
71 |
-
<h2>Conclusion</h2>
|
72 |
-
<p>Coin Master card download is an exciting and rewarding feature of the game that allows you to collect and trade cards with other players. By following the tips and tricks we shared in this article, you can improve your chances of completing your card sets and advancing in the game. Remember to join a card trading group, use your Joker card wisely, and complete card sets before moving to the next village. Happy spinning!</p>
|
73 |
-
<h3>FAQs</h3>
|
74 |
-
<p>Here are some frequently asked questions about Coin Master card download:</p>
|
75 |
-
<ol>
|
76 |
-
<li>How many cards are there in Coin Master?</li>
|
77 |
-
<p>There are over 300 cards in Coin Master, divided into 33 sets and 11 categories.</p>
|
78 |
-
<li>How do I know which cards I need?</li>
|
79 |
-
<p>You can check which cards you need by tapping on the menu icon on the top right corner of the screen and then selecting "Cards". You will see your card collection and the progress of each set. You can also tap on a specific card to see its details and value.</p>
|
80 |
-
<li>How do I know which cards I have extra?</li>
|
81 |
-
<p>You can check which cards you have extra by tapping on the menu icon on the top right corner of the screen and then selecting "Trade". You will see a list of your available trades and the number of cards you have for each one.</p>
|
82 |
-
<li>Can I buy or sell cards with real money?</li>
|
83 |
-
<p>No, you cannot buy or sell cards with real money in Coin Master. This is against the game's terms of service and may result in your account being banned or suspended.</p>
|
84 |
-
<li>Can I trade cards with anyone?</li>
|
85 |
-
<p>You can trade cards with anyone who is online and has posted a trade that matches yours. You can also trade cards with your friends who are connected to Facebook.</p>
|
86 |
-
</ol></p> 197e85843d<br />
|
87 |
-
<br />
|
88 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/1pelhydcardo/ChatGPT-prompt-generator/assets/Download Garena Free Fire APK v1.38.2 - The Best Online Multiplayer Battle Royale Game.md
DELETED
@@ -1,134 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Download Garena Free Fire APK v1.38.2: A Guide for Beginners</h1>
|
3 |
-
<p>If you are looking for a thrilling and action-packed mobile game, you might want to try Garena Free Fire, one of the most popular battle royale games on Android and iOS devices. In this article, we will show you how to download Garena Free Fire APK v1.38.2, the latest version of the game, and give you some tips and tricks on how to play it.</p>
|
4 |
-
<h2>download garena free fire apk v1.38.2</h2><br /><p><b><b>Download File</b> ⭐ <a href="https://urlin.us/2uT0qW">https://urlin.us/2uT0qW</a></b></p><br /><br />
|
5 |
-
<h2>What is Garena Free Fire?</h2>
|
6 |
-
<p>Garena Free Fire is a mobile game that has quickly gained popularity since its release in 2017. The game is set in a fictional world where players are parachuted onto an island and must find weapons and gear to survive. The game offers a thrilling multiplayer experience where players fight to be the last ones standing on a remote island.</p>
|
7 |
-
<h3>A popular mobile battle royale game</h3>
|
8 |
-
<p>Garena Free Fire is a mobile game that belongs to the battle royale genre, which means that players are dropped into an arena where they have to fight each other until only one player or team remains alive. The game can be downloaded for free from the Google Play Store and the App Store, and offers in-app purchases for various items and features.</p>
|
9 |
-
<p>The game has over 1 billion downloads on Google Play and has won several awards, such as the Best Popular Vote Game by Google Play in 2019, and the Most Competitive Game by Google Play in 2020.</p>
|
10 |
-
<h3>Features and modes of the game</h3>
|
11 |
-
<p>Garena Free Fire has many features and modes that make it an exciting and diverse game to play. Some of the key features of the game are:</p>
|
12 |
-
<p>How to download garena free fire apk v1.38.2 on android<br />
|
13 |
-
Download garena free fire apk v1.38.2 latest version for free<br />
|
14 |
-
Garena free fire apk v1.38.2 mod menu download<br />
|
15 |
-
Download garena free fire apk v1.38.2 obb file<br />
|
16 |
-
Garena free fire apk v1.38.2 update download<br />
|
17 |
-
Download garena free fire apk v1.38.2 from APKCombo[^1^]<br />
|
18 |
-
Garena free fire apk v1.38.2 download for pc<br />
|
19 |
-
Download garena free fire apk v1.38.2 offline installer<br />
|
20 |
-
Garena free fire apk v1.38.2 hack download<br />
|
21 |
-
Download garena free fire apk v1.38.2 without verification<br />
|
22 |
-
Garena free fire apk v1.38.2 download link<br />
|
23 |
-
Download garena free fire apk v1.38.2 from Garena Free Fire website[^2^]<br />
|
24 |
-
Garena free fire apk v1.38.2 download size<br />
|
25 |
-
Download garena free fire apk v1.38.2 with unlimited diamonds<br />
|
26 |
-
Garena free fire apk v1.38.2 gameplay download<br />
|
27 |
-
Download garena free fire apk v1.38.2 for ios<br />
|
28 |
-
Garena free fire apk v1.38.2 review download<br />
|
29 |
-
Download garena free fire apk v1.38.2 from Google Play Store<br />
|
30 |
-
Garena free fire apk v1.38.2 features download<br />
|
31 |
-
Download garena free fire apk v1.38.2 with aimbot<br />
|
32 |
-
Garena free fire apk v1.38.2 system requirements download<br />
|
33 |
-
Download garena free fire apk v1.38.2 for windows 10<br />
|
34 |
-
Garena free fire apk v1.38.2 tips and tricks download<br />
|
35 |
-
Download garena free fire apk v1.38.2 from APKPure<br />
|
36 |
-
Garena free fire apk v1.38.2 best settings download<br />
|
37 |
-
Download garena free fire apk v1.38.2 with headshot hack<br />
|
38 |
-
Garena free fire apk v1.38.2 new map download<br />
|
39 |
-
Download garena free fire apk v1.38.2 from MediaFire<br />
|
40 |
-
Garena free fire apk v1.38.2 skins download<br />
|
41 |
-
Download garena free fire apk v1.38.2 with anti-ban<br />
|
42 |
-
Garena free fire apk v1.38.2 characters download<br />
|
43 |
-
Download garena free fire apk v1.38.2 for mac<br />
|
44 |
-
Garena free fire apk v1.38.2 weapons download<br />
|
45 |
-
Download garena free fire apk v1.38.2 from Uptodown<br />
|
46 |
-
Garena free fire apk v1.38.2 graphics download<br />
|
47 |
-
Download garena free fire apk v1.38.2 with wallhack<br />
|
48 |
-
Garena free fire apk v1.38.2 ranking system download<br />
|
49 |
-
Download garena free fire apk v1.38.2 from APKMirror<br />
|
50 |
-
Garena free fire apk v1 38 2 guide download</p>
|
51 |
-
<ul>
|
52 |
-
<li>The game has over 15 characters, each with their own unique skills and abilities that can help players in different situations.</li>
|
53 |
-
<li>The game has two maps, Bermuda and Purgatory, each with different terrains, locations, and challenges.</li>
|
54 |
-
<li>The game has over 15 game modes, including Team Deathmatch, Clash Squad, Big Head, Explosive Jump, Cold Steel, Rampage, and Pet Mania. However, modes other than Battle Royale, Clash Squad, and Lone Wolf are only available during special events.</li>
|
55 |
-
<li>The game has realistic and smooth graphics, easy to use controls, and in-game voice chat that allow players to enjoy the optimum survival experience on mobile devices.</li>
|
56 |
-
</ul>
|
57 |
-
<h2>How to download Garena Free Fire APK v1.38.2?</h2>
|
58 |
-
<p>If you want to download Garena Free Fire APK v1.38.2, which is the latest version of the game as of June 2023, you need to follow some simple steps. However, before you do that, you need to make sure that your device meets the requirements and compatibility of the game.</p>
|
59 |
-
<h3>Requirements and compatibility</h3>
|
60 |
-
<p>Garena Free Fire APK v1.38.2 requires Android 4.0.3 or higher to run smoothly on your device. The size of the APK file is about 500 MB, so you need to have enough storage space on your device before downloading it.</p>
|
61 |
-
<p>The game is compatible with most Android devices, but some models may have problems running it due to hardware limitations or software issues. If you encounter any problems while playing the game, you can contact the customer service of Garena Free Fire through their official website or social media channels.</p>
|
62 |
-
<h3>Steps to download and install the APK file</h3>
|
63 |
-
<p>To download Garena Free Fire APK v1.38.2, you need to follow these steps:</p>
|
64 |
-
<ol>
|
65 |
-
<li>Go to [Garena Free Fire - Official Website] and click on the Download button. Alternatively, you can use this [direct link] to download the APK file.</li>
|
66 |
-
<li>Once the download is complete, locate the APK file on your device and tap on it to install it. You may need to enable the installation of apps from unknown sources in your device settings.</li>
|
67 |
-
<li>After the installation is done, launch the game and enjoy the latest features and updates of Garena Free Fire.</li>
|
68 |
-
</ol>
|
69 |
-
<h2>How to play Garena Free Fire?</h2>
|
70 |
-
<p>Now that you have downloaded and installed Garena Free Fire APK v1.38.2, you might be wondering how to play the game and win more matches. Here are some tips and tricks for beginners that can help you improve your skills and have more fun in the game.</p>
|
71 |
-
<h3>Tips and tricks for beginners</h3>
|
72 |
-
<p>Garena Free Fire is a game that requires strategy, skill, and luck to survive and win. Here are some tips and tricks that can help you get started:</p>
|
73 |
-
<ul>
|
74 |
-
<li>Choose your character wisely. Each character has a unique skill that can give you an edge in different situations. For example, Kelly has increased sprinting speed, Alok can create a healing aura, and Chrono can create a force field that blocks damage.</li>
|
75 |
-
<li>Loot fast and smart. As soon as you land on the island, you need to find weapons, armor, ammo, and other items that can help you survive. However, you also need to be careful of enemies who might be nearby. Try to loot in areas that are less crowded and have good cover.</li>
|
76 |
-
<li>Use vehicles to move around. Vehicles are a great way to travel faster and escape from danger. However, they also make noise and attract attention, so use them wisely. You can also use vehicles as weapons by running over enemies or exploding them.</li>
|
77 |
-
<li>Stay in the safe zone. The safe zone is the area where you will not take damage from the shrinking circle of fire. You need to keep an eye on the map and move towards the safe zone as soon as possible. However, be aware of enemies who might be camping or ambushing near the edge of the zone.</li>
|
78 |
-
<li>Use cover and stealth. Cover is anything that can protect you from enemy fire, such as buildings, trees, rocks, or vehicles. Stealth is the ability to move without being seen or heard by enemies. You can use cover and stealth to hide, scout, snipe, or flank enemies.</li>
|
79 |
-
</ul>
|
80 |
-
<h3>Reviews and ratings of the game</h3>
|
81 |
-
<p>Garena Free Fire has received mostly positive reviews and ratings from players and critics alike. The game has a 4.3 out of 5 stars rating on Google Play and a 4.6 out of 5 stars rating on App Store. </p>
|
82 |
-
<p>Some of the pros of the game are:</p>
|
83 |
-
<ul>
|
84 |
-
<li>The game is free to play and offers a lot of content and variety.</li>
|
85 |
-
<li>The game has smooth and realistic graphics and sound effects.</li>
|
86 |
-
<li>The game has a large and active community of players and streamers.</li>
|
87 |
-
</ul>
|
88 |
-
<p>Some of the cons of the game are:</p>
|
89 |
-
<ul>
|
90 |
-
<li>The game can be laggy or buggy at times due to server issues or device compatibility.</li>
|
91 |
-
<li>The game can be challenging or frustrating for new or casual players due to the high level of competition.</li>
|
92 |
-
<li>The game can be addictive or harmful for mental health if played excessively or irresponsibly.</li>
|
93 |
-
</ul>
|
94 |
-
<h2>Conclusion</h2>
|
95 |
-
<p>Garena Free Fire is a mobile game that offers a thrilling and action-packed survival experience for players who love battle royale games. The game can be downloaded for free from the Google Play Store or App Store, or by using the APK file provided in this article.</p>
|
96 |
-
<p>If you want to enjoy the latest version of the game, which is Garena Free Fire APK v1.38.2, you need to follow some simple steps to download and install it on your device. You also need to learn some tips and tricks on how to play the game and win more matches.</p>
|
97 |
-
<p>Garena Free Fire is a game that has many pros and cons, depending on your preferences and expectations. However, it is undeniable that it is one of the most popular and exciting mobile games in the world right now.</p>
|
98 |
-
<h2>FAQs</h2>
|
99 |
-
<p>Here are some frequently asked questions about Garena Free Fire:</p>
|
100 |
-
<h4>Q: Is Garena Free Fire safe to download?</h4>
|
101 |
-
<p>A: Yes, Garena Free Fire is safe to download as long as you use the official website or the trusted app stores. However, you should be careful of downloading the APK file from unknown or unverified sources, as they may contain malware or viruses that can harm your device or steal your data.</p>
|
102 |
-
<h4>Q: How to update Garena Free Fire?</h4>
|
103 |
-
<p>A: Garena Free Fire usually updates automatically when you launch the game, as long as you have a stable internet connection and enough storage space on your device. However, if you want to update the game manually, you can do so by following these steps:</p>
|
104 |
-
<ol>
|
105 |
-
<li>Go to the Google Play Store or App Store and search for Garena Free Fire.</li>
|
106 |
-
<li>Tap on the Update button and wait for the download and installation to finish.</li>
|
107 |
-
<li>Launch the game and enjoy the new features and improvements.</li>
|
108 |
-
</ol>
|
109 |
-
<h4>Q: How to get diamonds in Garena Free Fire?</h4>
|
110 |
-
<p>A: Diamonds are the premium currency in Garena Free Fire that can be used to buy various items and features in the game, such as characters, skins, pets, crates, bundles, and more. There are several ways to get diamonds in Garena Free Fire, such as:</p>
|
111 |
-
<ul>
|
112 |
-
<li>Buying them with real money through the in-game store or third-party platforms.</li>
|
113 |
-
<li>Earning them by completing tasks, surveys, offers, or watching ads through various apps or websites that partner with Garena Free Fire.</li>
|
114 |
-
<li>Winning them by participating in events, tournaments, giveaways, or contests organized by Garena Free Fire or its affiliates.</li>
|
115 |
-
</ul>
|
116 |
-
<h4>Q: How to get free fire redeem codes?</h4>
|
117 |
-
<p>A: Redeem codes are codes that can be used to get free rewards in Garena Free Fire, such as diamonds, coins, skins, crates, vouchers, and more. Redeem codes are usually given out by Garena Free Fire or its partners through their official social media channels, websites, or live streams. To get free fire redeem codes, you need to follow these steps:</p>
|
118 |
-
<ol>
|
119 |
-
<li>Find a valid and working redeem code from a reliable source. You can check the official social media pages of Garena Free Fire or its partners for the latest codes.</li>
|
120 |
-
<li>Go to [Garena Free Fire - Redemption Center] and log in with your Facebook, Google, VK, Apple ID, Huawei ID, or Twitter account that is linked to your game account.</li>
|
121 |
-
<li>Enter the redeem code in the box and click on Confirm.</li>
|
122 |
-
<li>Check your in-game mail for the reward and claim it within 24 hours.</li>
|
123 |
-
</ol>
|
124 |
-
<h4>Q: How to contact Garena Free Fire customer service?</h4>
|
125 |
-
<p>A: If you have any questions, issues, feedback, or suggestions regarding Garena Free Fire, you can contact their customer service through various channels, such as:</p>
|
126 |
-
<ul>
|
127 |
-
<li>Email: [[email protected]]</li>
|
128 |
-
<li>Website: [Garena Free Fire - Support]</li>
|
129 |
-
<li>Facebook: [Garena Free Fire]</li>
|
130 |
-
<li>Instagram: [@freefireth]</li>
|
131 |
-
<li>Twitter: [@freefireth]</li>
|
132 |
-
</ul></p> 197e85843d<br />
|
133 |
-
<br />
|
134 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/7hao/bingo/src/components/ui/alert-dialog.tsx
DELETED
@@ -1,150 +0,0 @@
|
|
1 |
-
'use client'
|
2 |
-
|
3 |
-
import * as React from 'react'
|
4 |
-
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
5 |
-
|
6 |
-
import { cn } from '@/lib/utils'
|
7 |
-
import { buttonVariants } from '@/components/ui/button'
|
8 |
-
|
9 |
-
const AlertDialog = AlertDialogPrimitive.Root
|
10 |
-
|
11 |
-
const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
12 |
-
|
13 |
-
const AlertDialogPortal = ({
|
14 |
-
className,
|
15 |
-
children,
|
16 |
-
...props
|
17 |
-
}: AlertDialogPrimitive.AlertDialogPortalProps) => (
|
18 |
-
<AlertDialogPrimitive.Portal className={cn(className)} {...props}>
|
19 |
-
<div className="fixed inset-0 z-50 flex items-end justify-center sm:items-center">
|
20 |
-
{children}
|
21 |
-
</div>
|
22 |
-
</AlertDialogPrimitive.Portal>
|
23 |
-
)
|
24 |
-
AlertDialogPortal.displayName = AlertDialogPrimitive.Portal.displayName
|
25 |
-
|
26 |
-
const AlertDialogOverlay = React.forwardRef<
|
27 |
-
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
28 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
29 |
-
>(({ className, children, ...props }, ref) => (
|
30 |
-
<AlertDialogPrimitive.Overlay
|
31 |
-
className={cn(
|
32 |
-
'fixed inset-0 z-50 bg-background/80 backdrop-blur-sm transition-opacity animate-in fade-in',
|
33 |
-
className
|
34 |
-
)}
|
35 |
-
{...props}
|
36 |
-
ref={ref}
|
37 |
-
/>
|
38 |
-
))
|
39 |
-
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
|
40 |
-
|
41 |
-
const AlertDialogContent = React.forwardRef<
|
42 |
-
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
43 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
44 |
-
>(({ className, ...props }, ref) => (
|
45 |
-
<AlertDialogPortal>
|
46 |
-
<AlertDialogOverlay />
|
47 |
-
<AlertDialogPrimitive.Content
|
48 |
-
ref={ref}
|
49 |
-
className={cn(
|
50 |
-
'fixed z-50 grid w-full max-w-lg scale-100 gap-4 border bg-background p-6 opacity-100 shadow-lg animate-in fade-in-90 slide-in-from-bottom-10 sm:rounded-lg sm:zoom-in-90 sm:slide-in-from-bottom-0 md:w-full',
|
51 |
-
className
|
52 |
-
)}
|
53 |
-
{...props}
|
54 |
-
/>
|
55 |
-
</AlertDialogPortal>
|
56 |
-
))
|
57 |
-
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
|
58 |
-
|
59 |
-
const AlertDialogHeader = ({
|
60 |
-
className,
|
61 |
-
...props
|
62 |
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
63 |
-
<div
|
64 |
-
className={cn(
|
65 |
-
'flex flex-col space-y-2 text-center sm:text-left',
|
66 |
-
className
|
67 |
-
)}
|
68 |
-
{...props}
|
69 |
-
/>
|
70 |
-
)
|
71 |
-
AlertDialogHeader.displayName = 'AlertDialogHeader'
|
72 |
-
|
73 |
-
const AlertDialogFooter = ({
|
74 |
-
className,
|
75 |
-
...props
|
76 |
-
}: React.HTMLAttributes<HTMLDivElement>) => (
|
77 |
-
<div
|
78 |
-
className={cn(
|
79 |
-
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
80 |
-
className
|
81 |
-
)}
|
82 |
-
{...props}
|
83 |
-
/>
|
84 |
-
)
|
85 |
-
AlertDialogFooter.displayName = 'AlertDialogFooter'
|
86 |
-
|
87 |
-
const AlertDialogTitle = React.forwardRef<
|
88 |
-
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
89 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
90 |
-
>(({ className, ...props }, ref) => (
|
91 |
-
<AlertDialogPrimitive.Title
|
92 |
-
ref={ref}
|
93 |
-
className={cn('text-lg font-semibold', className)}
|
94 |
-
{...props}
|
95 |
-
/>
|
96 |
-
))
|
97 |
-
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
|
98 |
-
|
99 |
-
const AlertDialogDescription = React.forwardRef<
|
100 |
-
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
101 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
102 |
-
>(({ className, ...props }, ref) => (
|
103 |
-
<AlertDialogPrimitive.Description
|
104 |
-
ref={ref}
|
105 |
-
className={cn('text-sm text-muted-foreground', className)}
|
106 |
-
{...props}
|
107 |
-
/>
|
108 |
-
))
|
109 |
-
AlertDialogDescription.displayName =
|
110 |
-
AlertDialogPrimitive.Description.displayName
|
111 |
-
|
112 |
-
const AlertDialogAction = React.forwardRef<
|
113 |
-
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
114 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
115 |
-
>(({ className, ...props }, ref) => (
|
116 |
-
<AlertDialogPrimitive.Action
|
117 |
-
ref={ref}
|
118 |
-
className={cn(buttonVariants(), className)}
|
119 |
-
{...props}
|
120 |
-
/>
|
121 |
-
))
|
122 |
-
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
|
123 |
-
|
124 |
-
const AlertDialogCancel = React.forwardRef<
|
125 |
-
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
126 |
-
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
127 |
-
>(({ className, ...props }, ref) => (
|
128 |
-
<AlertDialogPrimitive.Cancel
|
129 |
-
ref={ref}
|
130 |
-
className={cn(
|
131 |
-
buttonVariants({ variant: 'outline' }),
|
132 |
-
'mt-2 sm:mt-0',
|
133 |
-
className
|
134 |
-
)}
|
135 |
-
{...props}
|
136 |
-
/>
|
137 |
-
))
|
138 |
-
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
|
139 |
-
|
140 |
-
export {
|
141 |
-
AlertDialog,
|
142 |
-
AlertDialogTrigger,
|
143 |
-
AlertDialogContent,
|
144 |
-
AlertDialogHeader,
|
145 |
-
AlertDialogFooter,
|
146 |
-
AlertDialogTitle,
|
147 |
-
AlertDialogDescription,
|
148 |
-
AlertDialogAction,
|
149 |
-
AlertDialogCancel
|
150 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AIGC-Audio/AudioGPT/NeuralSeq/egs/datasets/audio/lj/preprocess.py
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
from data_gen.tts.base_preprocess import BasePreprocessor
|
2 |
-
|
3 |
-
|
4 |
-
class LJPreprocess(BasePreprocessor):
|
5 |
-
def meta_data(self):
|
6 |
-
for l in open(f'{self.raw_data_dir}/metadata.csv').readlines():
|
7 |
-
item_name, _, txt = l.strip().split("|")
|
8 |
-
wav_fn = f"{self.raw_data_dir}/wavs/{item_name}.wav"
|
9 |
-
yield {'item_name': item_name, 'wav_fn': wav_fn, 'txt': txt}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AIGC-Audio/Make_An_Audio_inpaint/ldm/modules/losses_audio/vggishish/train_vggishish.py
DELETED
@@ -1,199 +0,0 @@
|
|
1 |
-
from loss import WeightedCrossEntropy
|
2 |
-
import random
|
3 |
-
|
4 |
-
import numpy as np
|
5 |
-
import torch
|
6 |
-
import torchvision
|
7 |
-
from omegaconf import OmegaConf
|
8 |
-
from torch.utils.data.dataloader import DataLoader
|
9 |
-
from tqdm import tqdm
|
10 |
-
|
11 |
-
from dataset import VGGSound
|
12 |
-
from transforms import Crop, StandardNormalizeAudio, ToTensor
|
13 |
-
from logger import LoggerWithTBoard
|
14 |
-
from metrics import metrics
|
15 |
-
from model import VGGishish
|
16 |
-
|
17 |
-
if __name__ == "__main__":
|
18 |
-
cfg_cli = OmegaConf.from_cli()
|
19 |
-
cfg_yml = OmegaConf.load(cfg_cli.config)
|
20 |
-
# the latter arguments are prioritized
|
21 |
-
cfg = OmegaConf.merge(cfg_yml, cfg_cli)
|
22 |
-
OmegaConf.set_readonly(cfg, True)
|
23 |
-
print(OmegaConf.to_yaml(cfg))
|
24 |
-
|
25 |
-
logger = LoggerWithTBoard(cfg)
|
26 |
-
|
27 |
-
random.seed(cfg.seed)
|
28 |
-
np.random.seed(cfg.seed)
|
29 |
-
torch.manual_seed(cfg.seed)
|
30 |
-
torch.cuda.manual_seed_all(cfg.seed)
|
31 |
-
# makes iterations faster (in this case 30%) if your inputs are of a fixed size
|
32 |
-
# https://discuss.pytorch.org/t/what-does-torch-backends-cudnn-benchmark-do/5936/3
|
33 |
-
torch.backends.cudnn.benchmark = True
|
34 |
-
|
35 |
-
transforms = [
|
36 |
-
StandardNormalizeAudio(cfg.mels_path),
|
37 |
-
]
|
38 |
-
if cfg.cropped_size not in [None, 'None', 'none']:
|
39 |
-
logger.print_logger.info(f'Using cropping {cfg.cropped_size}')
|
40 |
-
transforms.append(Crop(cfg.cropped_size))
|
41 |
-
transforms.append(ToTensor())
|
42 |
-
transforms = torchvision.transforms.transforms.Compose(transforms)
|
43 |
-
|
44 |
-
datasets = {
|
45 |
-
'train': VGGSound('train', cfg.mels_path, transforms),
|
46 |
-
'valid': VGGSound('valid', cfg.mels_path, transforms),
|
47 |
-
'test': VGGSound('test', cfg.mels_path, transforms),
|
48 |
-
}
|
49 |
-
|
50 |
-
loaders = {
|
51 |
-
'train': DataLoader(datasets['train'], batch_size=cfg.batch_size, shuffle=True, drop_last=True,
|
52 |
-
num_workers=cfg.num_workers, pin_memory=True),
|
53 |
-
'valid': DataLoader(datasets['valid'], batch_size=cfg.batch_size,
|
54 |
-
num_workers=cfg.num_workers, pin_memory=True),
|
55 |
-
'test': DataLoader(datasets['test'], batch_size=cfg.batch_size,
|
56 |
-
num_workers=cfg.num_workers, pin_memory=True),
|
57 |
-
}
|
58 |
-
|
59 |
-
device = torch.device(cfg.device if torch.cuda.is_available() else 'cpu')
|
60 |
-
|
61 |
-
model = VGGishish(cfg.conv_layers, cfg.use_bn, num_classes=len(datasets['train'].target2label))
|
62 |
-
model = model.to(device)
|
63 |
-
param_num = logger.log_param_num(model)
|
64 |
-
|
65 |
-
if cfg.optimizer == 'adam':
|
66 |
-
optimizer = torch.optim.Adam(
|
67 |
-
model.parameters(), lr=cfg.learning_rate, betas=cfg.betas, weight_decay=cfg.weight_decay)
|
68 |
-
elif cfg.optimizer == 'sgd':
|
69 |
-
optimizer = torch.optim.SGD(
|
70 |
-
model.parameters(), lr=cfg.learning_rate, momentum=cfg.momentum, weight_decay=cfg.weight_decay)
|
71 |
-
else:
|
72 |
-
raise NotImplementedError
|
73 |
-
|
74 |
-
if cfg.cls_weights_in_loss:
|
75 |
-
weights = 1 / datasets['train'].class_counts
|
76 |
-
else:
|
77 |
-
weights = torch.ones(len(datasets['train'].target2label))
|
78 |
-
criterion = WeightedCrossEntropy(weights.to(device))
|
79 |
-
|
80 |
-
# loop over the train and validation multiple times (typical PT boilerplate)
|
81 |
-
no_change_epochs = 0
|
82 |
-
best_valid_loss = float('inf')
|
83 |
-
early_stop_triggered = False
|
84 |
-
|
85 |
-
for epoch in range(cfg.num_epochs):
|
86 |
-
|
87 |
-
for phase in ['train', 'valid']:
|
88 |
-
if phase == 'train':
|
89 |
-
model.train()
|
90 |
-
else:
|
91 |
-
model.eval()
|
92 |
-
|
93 |
-
running_loss = 0
|
94 |
-
preds_from_each_batch = []
|
95 |
-
targets_from_each_batch = []
|
96 |
-
|
97 |
-
prog_bar = tqdm(loaders[phase], f'{phase} ({epoch})', ncols=0)
|
98 |
-
for i, batch in enumerate(prog_bar):
|
99 |
-
inputs = batch['input'].to(device)
|
100 |
-
targets = batch['target'].to(device)
|
101 |
-
|
102 |
-
# zero the parameter gradients
|
103 |
-
optimizer.zero_grad()
|
104 |
-
|
105 |
-
# forward + backward + optimize
|
106 |
-
with torch.set_grad_enabled(phase == 'train'):
|
107 |
-
outputs = model(inputs)
|
108 |
-
loss = criterion(outputs, targets, to_weight=phase == 'train')
|
109 |
-
|
110 |
-
if phase == 'train':
|
111 |
-
loss.backward()
|
112 |
-
optimizer.step()
|
113 |
-
|
114 |
-
# loss
|
115 |
-
running_loss += loss.item()
|
116 |
-
|
117 |
-
# for metrics calculation later on
|
118 |
-
preds_from_each_batch += [outputs.detach().cpu()]
|
119 |
-
targets_from_each_batch += [targets.cpu()]
|
120 |
-
|
121 |
-
# iter logging
|
122 |
-
if i % 50 == 0:
|
123 |
-
logger.log_iter_loss(loss.item(), epoch*len(loaders[phase])+i, phase)
|
124 |
-
# tracks loss in the tqdm progress bar
|
125 |
-
prog_bar.set_postfix(loss=loss.item())
|
126 |
-
|
127 |
-
# logging loss
|
128 |
-
epoch_loss = running_loss / len(loaders[phase])
|
129 |
-
logger.log_epoch_loss(epoch_loss, epoch, phase)
|
130 |
-
|
131 |
-
# logging metrics
|
132 |
-
preds_from_each_batch = torch.cat(preds_from_each_batch)
|
133 |
-
targets_from_each_batch = torch.cat(targets_from_each_batch)
|
134 |
-
metrics_dict = metrics(targets_from_each_batch, preds_from_each_batch)
|
135 |
-
logger.log_epoch_metrics(metrics_dict, epoch, phase)
|
136 |
-
|
137 |
-
# Early stopping
|
138 |
-
if phase == 'valid':
|
139 |
-
if epoch_loss < best_valid_loss:
|
140 |
-
no_change_epochs = 0
|
141 |
-
best_valid_loss = epoch_loss
|
142 |
-
logger.log_best_model(model, epoch_loss, epoch, optimizer, metrics_dict)
|
143 |
-
else:
|
144 |
-
no_change_epochs += 1
|
145 |
-
logger.print_logger.info(
|
146 |
-
f'Valid loss hasnt changed for {no_change_epochs} patience: {cfg.patience}'
|
147 |
-
)
|
148 |
-
if no_change_epochs >= cfg.patience:
|
149 |
-
early_stop_triggered = True
|
150 |
-
|
151 |
-
if early_stop_triggered:
|
152 |
-
logger.print_logger.info(f'Training is early stopped @ {epoch}')
|
153 |
-
break
|
154 |
-
|
155 |
-
logger.print_logger.info('Finished Training')
|
156 |
-
|
157 |
-
# loading the best model
|
158 |
-
ckpt = torch.load(logger.best_model_path)
|
159 |
-
model.load_state_dict(ckpt['model'])
|
160 |
-
logger.print_logger.info(f'Loading the best model from {logger.best_model_path}')
|
161 |
-
logger.print_logger.info((f'The model was trained for {ckpt["epoch"]} epochs. Loss: {ckpt["loss"]:.4f}'))
|
162 |
-
|
163 |
-
# Testing the model
|
164 |
-
model.eval()
|
165 |
-
running_loss = 0
|
166 |
-
preds_from_each_batch = []
|
167 |
-
targets_from_each_batch = []
|
168 |
-
|
169 |
-
for i, batch in enumerate(loaders['test']):
|
170 |
-
inputs = batch['input'].to(device)
|
171 |
-
targets = batch['target'].to(device)
|
172 |
-
|
173 |
-
# zero the parameter gradients
|
174 |
-
optimizer.zero_grad()
|
175 |
-
|
176 |
-
# forward + backward + optimize
|
177 |
-
with torch.set_grad_enabled(False):
|
178 |
-
outputs = model(inputs)
|
179 |
-
loss = criterion(outputs, targets, to_weight=False)
|
180 |
-
|
181 |
-
# loss
|
182 |
-
running_loss += loss.item()
|
183 |
-
|
184 |
-
# for metrics calculation later on
|
185 |
-
preds_from_each_batch += [outputs.detach().cpu()]
|
186 |
-
targets_from_each_batch += [targets.cpu()]
|
187 |
-
|
188 |
-
# logging metrics
|
189 |
-
preds_from_each_batch = torch.cat(preds_from_each_batch)
|
190 |
-
targets_from_each_batch = torch.cat(targets_from_each_batch)
|
191 |
-
test_metrics_dict = metrics(targets_from_each_batch, preds_from_each_batch)
|
192 |
-
test_metrics_dict['avg_loss'] = running_loss / len(loaders['test'])
|
193 |
-
test_metrics_dict['param_num'] = param_num
|
194 |
-
# TODO: I have no idea why tboard doesn't keep metrics (hparams) when
|
195 |
-
# I run this experiment from cli: `python train_vggishish.py config=./configs/vggish.yaml`
|
196 |
-
# while when I run it in vscode debugger the metrics are logger (wtf)
|
197 |
-
logger.log_test_metrics(test_metrics_dict, dict(cfg), ckpt['epoch'])
|
198 |
-
|
199 |
-
logger.print_logger.info('Finished the experiment')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AILab-CVC/SEED-LLaMA/gradio_demo/seed_llama_gradio.py
DELETED
@@ -1,497 +0,0 @@
|
|
1 |
-
import hydra
|
2 |
-
|
3 |
-
import pyrootutils
|
4 |
-
import os
|
5 |
-
import torch
|
6 |
-
|
7 |
-
import datetime
|
8 |
-
from omegaconf import OmegaConf
|
9 |
-
# from flask import Flask, request
|
10 |
-
import json
|
11 |
-
from typing import Optional
|
12 |
-
import transformers
|
13 |
-
from dataclasses import dataclass, field
|
14 |
-
import io
|
15 |
-
import base64
|
16 |
-
from PIL import Image
|
17 |
-
import gradio as gr
|
18 |
-
import random
|
19 |
-
import time
|
20 |
-
import hashlib
|
21 |
-
import requests
|
22 |
-
|
23 |
-
from utils import build_logger
|
24 |
-
from conversation import conv_seed_vicuna, conv_seed_llama2
|
25 |
-
# from conversation import conv_seed_llama
|
26 |
-
|
27 |
-
IMG_FLAG = '<image>'
|
28 |
-
|
29 |
-
# request_address = 'http://11.29.21.161:80/generate'
|
30 |
-
# request_address = 'http://0.0.0.0:7890/generate'
|
31 |
-
LOGDIR = 'log'
|
32 |
-
|
33 |
-
logger = build_logger("gradio_seed_llama", LOGDIR)
|
34 |
-
headers = {"User-Agent": "SEED LLaMA Client"}
|
35 |
-
|
36 |
-
no_change_btn = gr.Button.update()
|
37 |
-
enable_btn = gr.Button.update(interactive=True)
|
38 |
-
disable_btn = gr.Button.update(interactive=False)
|
39 |
-
|
40 |
-
@dataclass
|
41 |
-
class Arguments:
|
42 |
-
server_port: Optional[int] = field(default=7860, metadata={"help": "network port"})
|
43 |
-
server_name: Optional[str] = field(default='0.0.0.0', metadata={"help": "network address"})
|
44 |
-
request_address: Optional[str] = field(default='http://127.0.0.1:7890/generate', metadata={"help": "request address"})
|
45 |
-
model_type: Optional[str] = field(default='seed-llama-14b', metadata={"help": "choice: [seed-llama-8b, seed-llama-14b]"})
|
46 |
-
|
47 |
-
parser = transformers.HfArgumentParser(Arguments)
|
48 |
-
args, = parser.parse_args_into_dataclasses()
|
49 |
-
|
50 |
-
if args.model_type == 'seed-llama-8b':
|
51 |
-
conv_seed_llama = conv_seed_vicuna
|
52 |
-
elif args.model_type == 'seed-llama-14b':
|
53 |
-
conv_seed_llama = conv_seed_llama2
|
54 |
-
else:
|
55 |
-
raise ValueError
|
56 |
-
|
57 |
-
|
58 |
-
def decode_image(encoded_image: str) -> Image:
|
59 |
-
decoded_bytes = base64.b64decode(encoded_image.encode('utf-8'))
|
60 |
-
# with io.BytesIO(decoded_bytes) as buffer:
|
61 |
-
# image = Image.open(buffer)
|
62 |
-
# return image
|
63 |
-
buffer = io.BytesIO(decoded_bytes)
|
64 |
-
image = Image.open(buffer)
|
65 |
-
return image
|
66 |
-
|
67 |
-
|
68 |
-
def encode_image(image: Image.Image, format: str = 'PNG') -> str:
|
69 |
-
with io.BytesIO() as buffer:
|
70 |
-
image.save(buffer, format=format)
|
71 |
-
encoded_image = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
72 |
-
return encoded_image
|
73 |
-
|
74 |
-
|
75 |
-
def get_conv_log_filename():
|
76 |
-
t = datetime.datetime.now()
|
77 |
-
name = os.path.join(LOGDIR, f"{t.year}-{t.month:02d}-{t.day:02d}-conv.json")
|
78 |
-
return name
|
79 |
-
|
80 |
-
|
81 |
-
def get_conv_image_dir():
|
82 |
-
name = os.path.join(LOGDIR, 'images')
|
83 |
-
os.makedirs(name, exist_ok=True)
|
84 |
-
return name
|
85 |
-
|
86 |
-
|
87 |
-
def get_image_name(image, image_dir=None):
|
88 |
-
buffer = io.BytesIO()
|
89 |
-
image.save(buffer, format='PNG')
|
90 |
-
image_bytes = buffer.getvalue()
|
91 |
-
md5 = hashlib.md5(image_bytes).hexdigest()
|
92 |
-
|
93 |
-
if image_dir is not None:
|
94 |
-
image_name = os.path.join(image_dir, md5 + '.png')
|
95 |
-
else:
|
96 |
-
image_name = md5 + '.png'
|
97 |
-
|
98 |
-
return image_name
|
99 |
-
|
100 |
-
|
101 |
-
def resize_image(image, max_size=512):
|
102 |
-
width, height = image.size
|
103 |
-
aspect_ratio = float(width) / float(height)
|
104 |
-
|
105 |
-
if width > height:
|
106 |
-
new_width = max_size
|
107 |
-
new_height = int(new_width / aspect_ratio)
|
108 |
-
else:
|
109 |
-
new_height = max_size
|
110 |
-
new_width = int(new_height * aspect_ratio)
|
111 |
-
|
112 |
-
resized_image = image.resize((new_width, new_height))
|
113 |
-
return resized_image
|
114 |
-
|
115 |
-
|
116 |
-
def center_crop_image(image, max_aspect_ratio=1.5):
|
117 |
-
width, height = image.size
|
118 |
-
aspect_ratio = max(width, height) / min(width, height)
|
119 |
-
|
120 |
-
if aspect_ratio >= max_aspect_ratio:
|
121 |
-
if width > height:
|
122 |
-
new_width = int(height * max_aspect_ratio)
|
123 |
-
left = (width - new_width) // 2
|
124 |
-
right = (width + new_width) // 2
|
125 |
-
top = 0
|
126 |
-
bottom = height
|
127 |
-
else:
|
128 |
-
new_height = int(width * max_aspect_ratio)
|
129 |
-
left = 0
|
130 |
-
right = width
|
131 |
-
top = (height - new_height) // 2
|
132 |
-
bottom = (height + new_height) // 2
|
133 |
-
|
134 |
-
cropped_image = image.crop((left, top, right, bottom))
|
135 |
-
return cropped_image
|
136 |
-
else:
|
137 |
-
return image
|
138 |
-
|
139 |
-
def vote_last_response(state, vote_type, request: gr.Request):
|
140 |
-
with open(get_conv_log_filename(), "a") as fout:
|
141 |
-
data = {
|
142 |
-
"tstamp": round(time.time(), 4),
|
143 |
-
"type": vote_type,
|
144 |
-
"state": state.dict(),
|
145 |
-
"ip": request.client.host,
|
146 |
-
}
|
147 |
-
fout.write(json.dumps(data) + "\n")
|
148 |
-
|
149 |
-
|
150 |
-
def upvote_last_response(state, request: gr.Request):
|
151 |
-
logger.info(f"upvote. ip: {request.client.host}")
|
152 |
-
vote_last_response(state, "upvote", request)
|
153 |
-
return (disable_btn, ) * 2
|
154 |
-
|
155 |
-
|
156 |
-
def downvote_last_response(state, request: gr.Request):
|
157 |
-
logger.info(f"downvote. ip: {request.client.host}")
|
158 |
-
vote_last_response(state, "downvote", request)
|
159 |
-
return (disable_btn, ) * 2
|
160 |
-
|
161 |
-
|
162 |
-
def regenerate(dialog_state, request: gr.Request):
|
163 |
-
logger.info(f"regenerate. ip: {request.client.host}")
|
164 |
-
if dialog_state.messages[-1]['role'] == dialog_state.roles[1]:
|
165 |
-
dialog_state.messages.pop()
|
166 |
-
return (
|
167 |
-
dialog_state,
|
168 |
-
dialog_state.to_gradio_chatbot(),
|
169 |
-
) + (disable_btn, ) * 4
|
170 |
-
|
171 |
-
|
172 |
-
def clear_history(request: gr.Request):
|
173 |
-
logger.info(f"clear_history. ip: {request.client.host}")
|
174 |
-
# state = None
|
175 |
-
# return (state, [], "") + (disable_btn, ) * 5
|
176 |
-
dialog_state = conv_seed_llama.copy()
|
177 |
-
input_state = init_input_state()
|
178 |
-
return (dialog_state, input_state, dialog_state.to_gradio_chatbot()) + (disable_btn, ) * 4
|
179 |
-
|
180 |
-
|
181 |
-
def init_input_state():
|
182 |
-
return {'images': [], 'text': '', 'images_ids': []}
|
183 |
-
|
184 |
-
|
185 |
-
def add_text(dialog_state, input_state, text, request: gr.Request):
|
186 |
-
logger.info(f"add_text. ip: {request.client.host}.")
|
187 |
-
# if len(input_state['text']) == 0:
|
188 |
-
if text is None or len(text) == 0:
|
189 |
-
# dialog_state.skip_next = True
|
190 |
-
return (dialog_state, input_state, "", dialog_state.to_gradio_chatbot()) + (no_change_btn, ) * 4
|
191 |
-
input_state['text'] += text
|
192 |
-
|
193 |
-
# dialog_state.skip_next = False
|
194 |
-
|
195 |
-
if len(dialog_state.messages) > 0 and dialog_state.messages[-1]['role'] == dialog_state.roles[0]:
|
196 |
-
dialog_state.messages[-1]['message'] = input_state
|
197 |
-
else:
|
198 |
-
dialog_state.messages.append({'role': dialog_state.roles[0], 'message': input_state})
|
199 |
-
print('add_text: ', dialog_state.to_gradio_chatbot())
|
200 |
-
|
201 |
-
return (dialog_state, input_state, "", dialog_state.to_gradio_chatbot()) + (disable_btn, ) * 4
|
202 |
-
|
203 |
-
|
204 |
-
def add_image(dialog_state, input_state, image, request: gr.Request):
|
205 |
-
logger.info(f"add_image. ip: {request.client.host}.")
|
206 |
-
if image is None:
|
207 |
-
return (dialog_state, input_state, None, dialog_state.to_gradio_chatbot()) + (no_change_btn, ) * 4
|
208 |
-
|
209 |
-
image = image.convert('RGB')
|
210 |
-
image = resize_image(image, max_size=512)
|
211 |
-
image = center_crop_image(image, max_aspect_ratio=1.3)
|
212 |
-
image_dir = get_conv_image_dir()
|
213 |
-
image_path = get_image_name(image=image, image_dir=image_dir)
|
214 |
-
if not os.path.exists(image_path):
|
215 |
-
image.save(image_path)
|
216 |
-
|
217 |
-
input_state['images'].append(image_path)
|
218 |
-
input_state['text'] += IMG_FLAG
|
219 |
-
input_state['images_ids'].append(None)
|
220 |
-
|
221 |
-
if len(dialog_state.messages) > 0 and dialog_state.messages[-1]['role'] == dialog_state.roles[0]:
|
222 |
-
dialog_state.messages[-1]['message'] = input_state
|
223 |
-
else:
|
224 |
-
dialog_state.messages.append({'role': dialog_state.roles[0], 'message': input_state})
|
225 |
-
|
226 |
-
print('add_image:', dialog_state)
|
227 |
-
|
228 |
-
return (dialog_state, input_state, None, dialog_state.to_gradio_chatbot()) + (disable_btn, ) * 4
|
229 |
-
|
230 |
-
|
231 |
-
def http_bot_test(dialog_state, input_state, temperature, top_p, max_new_tokens, num_beams, max_turns, force_image_gen, request: gr.Request):
|
232 |
-
logger.info(f"http_bot. ip: {request.client.host}")
|
233 |
-
output_state = {}
|
234 |
-
output_state['text'] = 'This is test for frontend!'
|
235 |
-
output_state['images'] = []
|
236 |
-
if len(dialog_state.messages) > 0 and len(dialog_state.messages[-1]['message']['images']) != 0:
|
237 |
-
image = random.choice(dialog_state.messages[-1]['message']['images'])
|
238 |
-
output_state['images'].append(image)
|
239 |
-
output_state['text'] += IMG_FLAG
|
240 |
-
|
241 |
-
dialog_state.messages.append({'role': dialog_state.roles[1], 'message': output_state})
|
242 |
-
input_state = init_input_state()
|
243 |
-
|
244 |
-
print('http_bot: ', dialog_state.to_gradio_chatbot())
|
245 |
-
|
246 |
-
return (dialog_state, input_state, dialog_state.to_gradio_chatbot()) + (enable_btn, ) * 4
|
247 |
-
|
248 |
-
|
249 |
-
def update_error_msg(chatbot, error_msg):
|
250 |
-
if len(error_msg) > 0:
|
251 |
-
info = '\n-------------\nSome errors occurred during response, please clear history and restart.\n' + '\n'.join(
|
252 |
-
error_msg)
|
253 |
-
chatbot[-1][-1] = chatbot[-1][-1] + info
|
254 |
-
|
255 |
-
return chatbot
|
256 |
-
|
257 |
-
|
258 |
-
def http_bot(dialog_state, input_state, temperature, top_p, max_new_tokens, num_beams, max_turns, force_image_gen, request: gr.Request):
|
259 |
-
logger.info(f"http_bot. ip: {request.client.host}")
|
260 |
-
print('input_state:', input_state)
|
261 |
-
|
262 |
-
if len(dialog_state.messages) == 0 or dialog_state.messages[-1]['role'] != dialog_state.roles[0] or len(
|
263 |
-
dialog_state.messages[-1]['message']['text'].strip(' ?.;!/')) == 0:
|
264 |
-
# if len(input_state['text']) == 0:
|
265 |
-
# dialog_state.skip_next = True
|
266 |
-
return (dialog_state, input_state, dialog_state.to_gradio_chatbot()) + (no_change_btn, ) * 4
|
267 |
-
|
268 |
-
if len(dialog_state.messages) > max_turns * 2:
|
269 |
-
output_state = init_input_state()
|
270 |
-
output_state['text'] = 'Error: History exceeds maximum rounds, please clear history and restart.'
|
271 |
-
dialog_state.messages.append({'role': dialog_state.roles[1], 'message': output_state})
|
272 |
-
input_state = init_input_state()
|
273 |
-
return (dialog_state, input_state, dialog_state.to_gradio_chatbot()) + (disable_btn, ) * 3 + (enable_btn, )
|
274 |
-
|
275 |
-
prompt = dialog_state.get_prompt()
|
276 |
-
payload = {
|
277 |
-
'text': prompt['text'],
|
278 |
-
'temperature': float(temperature),
|
279 |
-
'top_p': float(top_p),
|
280 |
-
'max_new_tokens': int(max_new_tokens),
|
281 |
-
'num_beams': int(num_beams),
|
282 |
-
'images': prompt['images'],
|
283 |
-
'force_boi': force_image_gen,
|
284 |
-
}
|
285 |
-
|
286 |
-
print(
|
287 |
-
'request: ', {
|
288 |
-
'text': prompt['text'],
|
289 |
-
'temperature': float(temperature),
|
290 |
-
'top_p': float(top_p),
|
291 |
-
'max_new_tokens': int(max_new_tokens),
|
292 |
-
'num_beams': int(num_beams)
|
293 |
-
})
|
294 |
-
print('request_address', args.request_address)
|
295 |
-
response = requests.request(method="POST", url=args.request_address, headers=headers, json=payload)
|
296 |
-
results = response.json()
|
297 |
-
print('response: ', {'text': results['text'], 'images_ids': results['images_ids'], 'error_msg': results['error_msg']})
|
298 |
-
|
299 |
-
output_state = init_input_state()
|
300 |
-
image_dir = get_conv_image_dir()
|
301 |
-
output_state['text'] = results['text']
|
302 |
-
|
303 |
-
for image_base64 in results['images']:
|
304 |
-
if image_base64 == '':
|
305 |
-
image_path = ''
|
306 |
-
else:
|
307 |
-
image = decode_image(image_base64)
|
308 |
-
image = image.convert('RGB')
|
309 |
-
image_path = get_image_name(image=image, image_dir=image_dir)
|
310 |
-
if not os.path.exists(image_path):
|
311 |
-
image.save(image_path)
|
312 |
-
output_state['images'].append(image_path)
|
313 |
-
output_state['images_ids'].append(None)
|
314 |
-
|
315 |
-
dialog_state.messages.append({'role': dialog_state.roles[1], 'message': output_state})
|
316 |
-
dialog_state.update_image_ids(results['images_ids'])
|
317 |
-
|
318 |
-
vote_last_response(dialog_state, 'common', request)
|
319 |
-
input_state = init_input_state()
|
320 |
-
chatbot = update_error_msg(dialog_state.to_gradio_chatbot(), results['error_msg'])
|
321 |
-
return (dialog_state, input_state, chatbot) + (enable_btn, ) * 4
|
322 |
-
|
323 |
-
|
324 |
-
def load_demo(request: gr.Request):
|
325 |
-
logger.info(f"load_demo. ip: {request.client.host}")
|
326 |
-
dialog_state = conv_seed_llama.copy()
|
327 |
-
input_state = init_input_state()
|
328 |
-
return dialog_state, input_state
|
329 |
-
|
330 |
-
|
331 |
-
title = ("""
|
332 |
-
# SEED-LLaMA-14B (8bit)
|
333 |
-
[[Project Page]](https://ailab-cvc.github.io/seed/seed_llama.html) [[Paper]](https://arxiv.org/pdf/2310.01218.pdf) [[Code]](https://github.com/AILab-CVC/SEED/tree/main)
|
334 |
-
|
335 |
-
## Tips:
|
336 |
-
* Check out the conversation examples (at the bottom) for inspiration.
|
337 |
-
|
338 |
-
* You can adjust "Max History Rounds" to try a conversation with up to five rounds. For more turns, you can download our checkpoints from GitHub and deploy them locally for inference.
|
339 |
-
|
340 |
-
* Our demo supports a mix of images and texts as input. You can freely upload an image or enter text, and then click on "Add Image/Text". You can repeat the former step multiple times, and click on "Submit" for model inference at last.
|
341 |
-
|
342 |
-
* If you are not satisfied with the output, especially the generated image, you may click on "Regenerate" for another chance.
|
343 |
-
|
344 |
-
* You can click "Force Image Generation" to compel the model to produce images when necessary. For example, our model might struggle to generate images when there is an excessive amount of text-only context.
|
345 |
-
* SEED-LLaMA was trained with English-only data. It may process with other languages due to the inherent capabilities from LLaMA, but might not stable.
|
346 |
-
""")
|
347 |
-
|
348 |
-
css = """
|
349 |
-
img {
|
350 |
-
font-family: 'Helvetica';
|
351 |
-
font-weight: 300;
|
352 |
-
line-height: 2;
|
353 |
-
text-align: center;
|
354 |
-
|
355 |
-
width: auto;
|
356 |
-
height: auto;
|
357 |
-
display: block;
|
358 |
-
position: relative;
|
359 |
-
}
|
360 |
-
|
361 |
-
img:before {
|
362 |
-
content: " ";
|
363 |
-
display: block;
|
364 |
-
|
365 |
-
position: absolute;
|
366 |
-
top: -10px;
|
367 |
-
left: 0;
|
368 |
-
height: calc(100% + 10px);
|
369 |
-
width: 100%;
|
370 |
-
background-color: rgb(230, 230, 230);
|
371 |
-
border: 2px dotted rgb(200, 200, 200);
|
372 |
-
border-radius: 5px;
|
373 |
-
}
|
374 |
-
|
375 |
-
img:after {
|
376 |
-
content: " ";
|
377 |
-
display: block;
|
378 |
-
font-size: 16px;
|
379 |
-
font-style: normal;
|
380 |
-
font-family: FontAwesome;
|
381 |
-
color: rgb(100, 100, 100);
|
382 |
-
|
383 |
-
position: absolute;
|
384 |
-
top: 5px;
|
385 |
-
left: 0;
|
386 |
-
width: 100%;
|
387 |
-
text-align: center;
|
388 |
-
}
|
389 |
-
|
390 |
-
"""
|
391 |
-
|
392 |
-
if __name__ == '__main__':
|
393 |
-
|
394 |
-
examples_mix = [
|
395 |
-
['images/cat.jpg', 'Add sunglasses to the animal.'],
|
396 |
-
['images/eagle.jpg', 'Transform this image into cartoon style'],
|
397 |
-
[None, 'Generate an image of dog on green grass.'],
|
398 |
-
[None, 'Draw a painting of sunflowers in Van Gogh style.'],
|
399 |
-
['images/dogs_4.jpg', 'How many dogs in the image?'],
|
400 |
-
['images/spongebob.png', 'Who are they?'],
|
401 |
-
['images/star.jpg', 'Do you know this painting?'],
|
402 |
-
]
|
403 |
-
|
404 |
-
examples_conv = [
|
405 |
-
['images/demo_example1.jpg'],
|
406 |
-
['images/demo_example2.jpg'],
|
407 |
-
['images/demo_example3.jpg'],
|
408 |
-
['images/demo_example7.jpg'],
|
409 |
-
['images/demo_example5.jpg'],
|
410 |
-
['images/demo_example6.jpg'],
|
411 |
-
]
|
412 |
-
|
413 |
-
with gr.Blocks(css=css) as demo:
|
414 |
-
gr.Markdown(title)
|
415 |
-
dialog_state = gr.State()
|
416 |
-
input_state = gr.State()
|
417 |
-
with gr.Row():
|
418 |
-
with gr.Column(scale=3):
|
419 |
-
with gr.Row():
|
420 |
-
image = gr.Image(type='pil', label='input_image')
|
421 |
-
with gr.Row():
|
422 |
-
text = gr.Textbox(lines=5,
|
423 |
-
show_label=False,
|
424 |
-
label='input_text',
|
425 |
-
elem_id='textbox',
|
426 |
-
placeholder="Enter text or add image, and press submit,").style(container=False)
|
427 |
-
with gr.Row():
|
428 |
-
add_image_btn = gr.Button("Add Image")
|
429 |
-
add_text_btn = gr.Button("Add Text")
|
430 |
-
|
431 |
-
submit_btn = gr.Button("Submit")
|
432 |
-
|
433 |
-
with gr.Row():
|
434 |
-
num_beams = gr.Slider(minimum=1, maximum=4, value=1, step=1, interactive=True, label="Num of Beams")
|
435 |
-
max_new_tokens = gr.Slider(minimum=64,
|
436 |
-
maximum=1024,
|
437 |
-
value=256,
|
438 |
-
step=64,
|
439 |
-
interactive=True,
|
440 |
-
label="Max New Tokens")
|
441 |
-
temperature = gr.Slider(minimum=0.0,
|
442 |
-
maximum=1.0,
|
443 |
-
value=1.0,
|
444 |
-
step=0.1,
|
445 |
-
interactive=True,
|
446 |
-
label="Temperature")
|
447 |
-
top_p = gr.Slider(minimum=0.0, maximum=1.0, value=0.5, step=0.1, interactive=True, label="Top P")
|
448 |
-
max_turns = gr.Slider(minimum=1, maximum=5, value=3, step=1, interactive=True, label="Max History Rounds")
|
449 |
-
force_img_gen = gr.Radio(choices=[True, False], value=False, label='Force Image Generation')
|
450 |
-
|
451 |
-
with gr.Column(scale=7):
|
452 |
-
chatbot = gr.Chatbot(elem_id='chatbot', label="SEED LLaMA").style(height=700)
|
453 |
-
with gr.Row():
|
454 |
-
upvote_btn = gr.Button(value="👍 Upvote", interactive=False)
|
455 |
-
downvote_btn = gr.Button(value="👎 Downvote", interactive=False)
|
456 |
-
regenerate_btn = gr.Button(value="🔄 Regenerate", interactive=False)
|
457 |
-
clear_btn = gr.Button(value="🗑️ Clear history", interactive=False)
|
458 |
-
|
459 |
-
# with gr.Row():
|
460 |
-
# gr.Examples(examples=examples_image, label='Image examples', inputs=[image])
|
461 |
-
with gr.Row():
|
462 |
-
# with gr.Column(scale=6):
|
463 |
-
gr.Examples(examples=examples_mix, label='Input examples', inputs=[image, text])
|
464 |
-
# with gr.Column(scale=0.4):
|
465 |
-
# gr.Examples(examples=examples_text, inputs=[text])
|
466 |
-
|
467 |
-
|
468 |
-
# with gr.Row():
|
469 |
-
# gr.Examples(examples=examples_2, inputs=[image])
|
470 |
-
|
471 |
-
with gr.Row():
|
472 |
-
# gr.Gallery(value=[Image.open(e[0]) for e in examples_conv], show_label=True, label="Example Conversations", elem_id="gallery",height=1400, object_fit='contain').style(grid=[3], height='auto')
|
473 |
-
gr.Gallery(value=[Image.open(e[0]) for e in examples_conv], show_label=True, label="Example Conversations", elem_id="gallery",height=1500, columns=[3], rows=[2])
|
474 |
-
|
475 |
-
# Register listeners
|
476 |
-
btn_list = [upvote_btn, downvote_btn, regenerate_btn, clear_btn]
|
477 |
-
upvote_btn.click(upvote_last_response, [dialog_state], [upvote_btn, downvote_btn])
|
478 |
-
downvote_btn.click(downvote_last_response, [dialog_state], [upvote_btn, downvote_btn])
|
479 |
-
regenerate_btn.click(regenerate, [dialog_state], [dialog_state, chatbot] + btn_list).then(
|
480 |
-
http_bot, [dialog_state, input_state, temperature, top_p, max_new_tokens, num_beams, max_turns, force_img_gen],
|
481 |
-
[dialog_state, input_state, chatbot] + btn_list)
|
482 |
-
add_image_btn.click(add_image, [dialog_state, input_state, image],
|
483 |
-
[dialog_state, input_state, image, chatbot] + btn_list)
|
484 |
-
|
485 |
-
add_text_btn.click(add_text, [dialog_state, input_state, text], [dialog_state, input_state, text, chatbot] + btn_list)
|
486 |
-
|
487 |
-
submit_btn.click(
|
488 |
-
add_image, [dialog_state, input_state, image], [dialog_state, input_state, image, chatbot] + btn_list).then(
|
489 |
-
add_text, [dialog_state, input_state, text],
|
490 |
-
[dialog_state, input_state, text, chatbot, upvote_btn, downvote_btn, regenerate_btn, clear_btn]).then(
|
491 |
-
http_bot, [dialog_state, input_state, temperature, top_p, max_new_tokens, num_beams, max_turns, force_img_gen],
|
492 |
-
[dialog_state, input_state, chatbot] + btn_list)
|
493 |
-
clear_btn.click(clear_history, None, [dialog_state, input_state, chatbot] + btn_list)
|
494 |
-
|
495 |
-
demo.load(load_demo, None, [dialog_state, input_state])
|
496 |
-
|
497 |
-
demo.launch(server_name=args.server_name, server_port=args.server_port, enable_queue=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/ATang0729/Forecast4Muses/Model/Model6/Model6_0_ClothesDetection/mmyolo/configs/custom_dataset/yolov7_l_syncbn_fast_6x32b-100e_coco.py
DELETED
@@ -1,554 +0,0 @@
|
|
1 |
-
_base_ = ['../_base_/default_runtime.py', '../_base_/det_p5_tta.py']
|
2 |
-
|
3 |
-
data_root = './data-df2/'
|
4 |
-
train_ann_file = 'annotations/train.json'
|
5 |
-
train_data_prefix = 'smaller-dataset/'
|
6 |
-
val_ann_file = 'annotations/val.json'
|
7 |
-
val_data_prefix = 'smaller-dataset/'
|
8 |
-
test_ann_file = 'annotations/test.json'
|
9 |
-
test_data_prefix = 'smaller-dataset/'
|
10 |
-
num_classes = 13
|
11 |
-
train_batch_size_per_gpu = 32
|
12 |
-
train_num_workers = 24
|
13 |
-
persistent_workers = True
|
14 |
-
|
15 |
-
vis_backends = [
|
16 |
-
dict(type='LocalVisBackend'),
|
17 |
-
]
|
18 |
-
visualizer = dict(
|
19 |
-
type='mmdet.DetLocalVisualizer',
|
20 |
-
vis_backends=[
|
21 |
-
dict(type='LocalVisBackend'),
|
22 |
-
dict(type='WandbVisBackend'),
|
23 |
-
# dict(type='TensorboardVisBackend')
|
24 |
-
],
|
25 |
-
name='visualizer')
|
26 |
-
log_processor = dict(type='LogProcessor', window_size=50, by_epoch=True)
|
27 |
-
log_level = 'INFO'
|
28 |
-
load_from = None
|
29 |
-
resume = False
|
30 |
-
|
31 |
-
anchors = [
|
32 |
-
[(12, 16), (19, 36), (40, 28)], # P3/8
|
33 |
-
[(36, 75), (76, 55), (72, 146)], # P4/16
|
34 |
-
[(142, 110), (192, 243), (459, 401)] # P5/32
|
35 |
-
]
|
36 |
-
|
37 |
-
base_lr = 0.01
|
38 |
-
max_epochs = 100
|
39 |
-
|
40 |
-
num_epoch_stage2 = 10 # The last 10 epochs switch evaluation interval
|
41 |
-
val_interval_stage2 = 1
|
42 |
-
|
43 |
-
model_test_cfg = dict(
|
44 |
-
multi_label=True,
|
45 |
-
nms_pre=30000,
|
46 |
-
score_thr=0.001,
|
47 |
-
nms=dict(type='nms', iou_threshold=0.65),
|
48 |
-
max_per_img=300)
|
49 |
-
|
50 |
-
img_scale = (640, 640)
|
51 |
-
dataset_type = 'YOLOv5CocoDataset'
|
52 |
-
metainfo = dict(
|
53 |
-
classes=(
|
54 |
-
'short_sleeved_shirt', 'long_sleeved_shirt',
|
55 |
-
'short_sleeved_outwear', 'long_sleeved_outwear',
|
56 |
-
'vest', 'sling', 'shorts', 'trousers', 'skirt',
|
57 |
-
'short_sleeved_dress', 'long_sleeved_dress',
|
58 |
-
'vest_dress', 'sling_dress'),
|
59 |
-
palette=[
|
60 |
-
(255, 0, 0),
|
61 |
-
(
|
62 |
-
255,
|
63 |
-
128,
|
64 |
-
0,
|
65 |
-
),
|
66 |
-
(
|
67 |
-
255,
|
68 |
-
255,
|
69 |
-
0,
|
70 |
-
),
|
71 |
-
(
|
72 |
-
128,
|
73 |
-
255,
|
74 |
-
0,
|
75 |
-
),
|
76 |
-
(
|
77 |
-
0,
|
78 |
-
255,
|
79 |
-
0,
|
80 |
-
),
|
81 |
-
(
|
82 |
-
0,
|
83 |
-
255,
|
84 |
-
128,
|
85 |
-
),
|
86 |
-
(
|
87 |
-
0,
|
88 |
-
255,
|
89 |
-
255,
|
90 |
-
),
|
91 |
-
(
|
92 |
-
0,
|
93 |
-
128,
|
94 |
-
255,
|
95 |
-
),
|
96 |
-
(
|
97 |
-
0,
|
98 |
-
0,
|
99 |
-
255,
|
100 |
-
),
|
101 |
-
(
|
102 |
-
127,
|
103 |
-
0,
|
104 |
-
255,
|
105 |
-
),
|
106 |
-
(
|
107 |
-
255,
|
108 |
-
0,
|
109 |
-
255,
|
110 |
-
),
|
111 |
-
(
|
112 |
-
255,
|
113 |
-
0,
|
114 |
-
127,
|
115 |
-
),
|
116 |
-
(
|
117 |
-
128,
|
118 |
-
128,
|
119 |
-
128,
|
120 |
-
),
|
121 |
-
])
|
122 |
-
|
123 |
-
val_batch_size_per_gpu = 1
|
124 |
-
val_num_workers = 2
|
125 |
-
batch_shapes_cfg = dict(
|
126 |
-
type='BatchShapePolicy',
|
127 |
-
batch_size=val_batch_size_per_gpu,
|
128 |
-
img_size=img_scale[0],
|
129 |
-
size_divisor=32,
|
130 |
-
extra_pad_ratio=0.5)
|
131 |
-
strides = [8, 16, 32] # Strides of multi-scale prior box
|
132 |
-
num_det_layers = 3
|
133 |
-
norm_cfg = dict(type='BN', momentum=0.03, eps=0.001)
|
134 |
-
|
135 |
-
# Data augmentation
|
136 |
-
max_translate_ratio = 0.2 # YOLOv5RandomAffine
|
137 |
-
scaling_ratio_range = (0.1, 2.0) # YOLOv5RandomAffine
|
138 |
-
mixup_prob = 0.15 # YOLOv5MixUp
|
139 |
-
randchoice_mosaic_prob = [0.8, 0.2]
|
140 |
-
mixup_alpha = 8.0 # YOLOv5MixUp
|
141 |
-
mixup_beta = 8.0 # YOLOv5MixUp
|
142 |
-
|
143 |
-
# -----train val related-----
|
144 |
-
loss_cls_weight = 0.3
|
145 |
-
loss_bbox_weight = 0.05
|
146 |
-
loss_obj_weight = 0.7
|
147 |
-
# BatchYOLOv7Assigner params
|
148 |
-
simota_candidate_topk = 10
|
149 |
-
simota_iou_weight = 3.0
|
150 |
-
simota_cls_weight = 1.0
|
151 |
-
prior_match_thr = 4. # Priori box matching threshold
|
152 |
-
obj_level_weights = [4., 1.,
|
153 |
-
0.4] # The obj loss weights of the three output layers
|
154 |
-
|
155 |
-
lr_factor = 0.1 # Learning rate scaling factor
|
156 |
-
weight_decay = 0.0005
|
157 |
-
save_epoch_intervals = 1
|
158 |
-
max_keep_ckpts = 5
|
159 |
-
|
160 |
-
env_cfg = dict(
|
161 |
-
cudnn_benchmark=True,
|
162 |
-
mp_cfg=dict(mp_start_method='fork', opencv_num_threads=0),
|
163 |
-
dist_cfg=dict(backend='nccl'))
|
164 |
-
|
165 |
-
# ===============================Unmodified in most cases====================
|
166 |
-
model = dict(
|
167 |
-
type='YOLODetector',
|
168 |
-
data_preprocessor=dict(
|
169 |
-
type='YOLOv5DetDataPreprocessor',
|
170 |
-
mean=[0., 0., 0.],
|
171 |
-
std=[255., 255., 255.],
|
172 |
-
bgr_to_rgb=True),
|
173 |
-
backbone=dict(
|
174 |
-
type='YOLOv7Backbone',
|
175 |
-
arch='L',
|
176 |
-
norm_cfg=norm_cfg,
|
177 |
-
act_cfg=dict(type='SiLU', inplace=True)),
|
178 |
-
neck=dict(
|
179 |
-
type='YOLOv7PAFPN',
|
180 |
-
block_cfg=dict(
|
181 |
-
type='ELANBlock',
|
182 |
-
middle_ratio=0.5,
|
183 |
-
block_ratio=0.25,
|
184 |
-
num_blocks=4,
|
185 |
-
num_convs_in_block=1),
|
186 |
-
upsample_feats_cat_first=False,
|
187 |
-
in_channels=[512, 1024, 1024],
|
188 |
-
# The real output channel will be multiplied by 2
|
189 |
-
out_channels=[128, 256, 512],
|
190 |
-
norm_cfg=norm_cfg,
|
191 |
-
act_cfg=dict(type='SiLU', inplace=True)),
|
192 |
-
bbox_head=dict(
|
193 |
-
type='YOLOv7Head',
|
194 |
-
head_module=dict(
|
195 |
-
type='YOLOv7HeadModule',
|
196 |
-
num_classes=num_classes,
|
197 |
-
in_channels=[256, 512, 1024],
|
198 |
-
featmap_strides=strides,
|
199 |
-
num_base_priors=3),
|
200 |
-
prior_generator=dict(
|
201 |
-
type='mmdet.YOLOAnchorGenerator',
|
202 |
-
base_sizes=anchors,
|
203 |
-
strides=strides),
|
204 |
-
# scaled based on number of detection layers
|
205 |
-
loss_cls=dict(
|
206 |
-
type='mmdet.CrossEntropyLoss',
|
207 |
-
use_sigmoid=True,
|
208 |
-
reduction='mean',
|
209 |
-
loss_weight=loss_cls_weight *
|
210 |
-
(num_classes / 80 * 3 / num_det_layers)),
|
211 |
-
loss_bbox=dict(
|
212 |
-
type='IoULoss',
|
213 |
-
iou_mode='ciou',
|
214 |
-
bbox_format='xyxy',
|
215 |
-
reduction='mean',
|
216 |
-
loss_weight=loss_bbox_weight * (3 / num_det_layers),
|
217 |
-
return_iou=True),
|
218 |
-
loss_obj=dict(
|
219 |
-
type='mmdet.CrossEntropyLoss',
|
220 |
-
use_sigmoid=True,
|
221 |
-
reduction='mean',
|
222 |
-
loss_weight=loss_obj_weight *
|
223 |
-
((img_scale[0] / 640)**2 * 3 / num_det_layers)),
|
224 |
-
prior_match_thr=prior_match_thr,
|
225 |
-
obj_level_weights=obj_level_weights,
|
226 |
-
# BatchYOLOv7Assigner params
|
227 |
-
simota_candidate_topk=simota_candidate_topk,
|
228 |
-
simota_iou_weight=simota_iou_weight,
|
229 |
-
simota_cls_weight=simota_cls_weight),
|
230 |
-
test_cfg=model_test_cfg)
|
231 |
-
|
232 |
-
pre_transform = [
|
233 |
-
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
|
234 |
-
dict(type='LoadAnnotations', with_bbox=True)
|
235 |
-
]
|
236 |
-
|
237 |
-
mosiac4_pipeline = [
|
238 |
-
dict(
|
239 |
-
type='Mosaic',
|
240 |
-
img_scale=img_scale,
|
241 |
-
pad_val=114.0,
|
242 |
-
pre_transform=pre_transform),
|
243 |
-
dict(
|
244 |
-
type='YOLOv5RandomAffine',
|
245 |
-
max_rotate_degree=0.0,
|
246 |
-
max_shear_degree=0.0,
|
247 |
-
max_translate_ratio=max_translate_ratio, # note
|
248 |
-
scaling_ratio_range=scaling_ratio_range, # note
|
249 |
-
# img_scale is (width, height)
|
250 |
-
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
251 |
-
border_val=(114, 114, 114)),
|
252 |
-
]
|
253 |
-
|
254 |
-
mosiac9_pipeline = [
|
255 |
-
dict(
|
256 |
-
type='Mosaic9',
|
257 |
-
img_scale=img_scale,
|
258 |
-
pad_val=114.0,
|
259 |
-
pre_transform=pre_transform),
|
260 |
-
dict(
|
261 |
-
type='YOLOv5RandomAffine',
|
262 |
-
max_rotate_degree=0.0,
|
263 |
-
max_shear_degree=0.0,
|
264 |
-
max_translate_ratio=max_translate_ratio, # note
|
265 |
-
scaling_ratio_range=scaling_ratio_range, # note
|
266 |
-
# img_scale is (width, height)
|
267 |
-
border=(-img_scale[0] // 2, -img_scale[1] // 2),
|
268 |
-
border_val=(114, 114, 114)),
|
269 |
-
]
|
270 |
-
|
271 |
-
randchoice_mosaic_pipeline = dict(
|
272 |
-
type='RandomChoice',
|
273 |
-
transforms=[mosiac4_pipeline, mosiac9_pipeline],
|
274 |
-
prob=randchoice_mosaic_prob)
|
275 |
-
|
276 |
-
train_pipeline = [
|
277 |
-
*pre_transform,
|
278 |
-
randchoice_mosaic_pipeline,
|
279 |
-
dict(
|
280 |
-
type='YOLOv5MixUp',
|
281 |
-
alpha=mixup_alpha, # note
|
282 |
-
beta=mixup_beta, # note
|
283 |
-
prob=mixup_prob,
|
284 |
-
pre_transform=[*pre_transform, randchoice_mosaic_pipeline]),
|
285 |
-
dict(type='YOLOv5HSVRandomAug'),
|
286 |
-
dict(type='mmdet.RandomFlip', prob=0.5),
|
287 |
-
dict(
|
288 |
-
type='mmdet.PackDetInputs',
|
289 |
-
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape', 'flip',
|
290 |
-
'flip_direction'))
|
291 |
-
]
|
292 |
-
|
293 |
-
test_pipeline = [
|
294 |
-
dict(type='LoadImageFromFile', file_client_args=_base_.file_client_args),
|
295 |
-
dict(type='YOLOv5KeepRatioResize', scale=img_scale),
|
296 |
-
dict(
|
297 |
-
type='LetterResize',
|
298 |
-
scale=img_scale,
|
299 |
-
allow_scale_up=False,
|
300 |
-
pad_val=dict(img=114)),
|
301 |
-
dict(type='LoadAnnotations', with_bbox=True, _scope_='mmdet'),
|
302 |
-
dict(
|
303 |
-
type='mmdet.PackDetInputs',
|
304 |
-
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
|
305 |
-
'scale_factor', 'pad_param'))
|
306 |
-
]
|
307 |
-
|
308 |
-
train_dataloader = dict(
|
309 |
-
batch_size=train_batch_size_per_gpu,
|
310 |
-
num_workers=train_num_workers,
|
311 |
-
persistent_workers=persistent_workers,
|
312 |
-
pin_memory=True,
|
313 |
-
sampler=dict(type='DefaultSampler', shuffle=True),
|
314 |
-
collate_fn=dict(type='yolov5_collate'), # FASTER
|
315 |
-
dataset=dict(
|
316 |
-
type='RepeatDataset',
|
317 |
-
times=2,
|
318 |
-
dataset=dict(
|
319 |
-
type=dataset_type,
|
320 |
-
metainfo=metainfo,
|
321 |
-
data_root=data_root,
|
322 |
-
ann_file=val_ann_file,
|
323 |
-
data_prefix=dict(img=train_data_prefix),
|
324 |
-
filter_cfg=dict(filter_empty_gt=False, min_size=32),
|
325 |
-
pipeline=train_pipeline
|
326 |
-
)
|
327 |
-
)
|
328 |
-
)
|
329 |
-
val_dataloader = dict(
|
330 |
-
dataset=dict(
|
331 |
-
type=dataset_type,
|
332 |
-
metainfo=metainfo,
|
333 |
-
data_root=data_root,
|
334 |
-
ann_file=val_ann_file,
|
335 |
-
data_prefix=dict(img=val_data_prefix)))
|
336 |
-
|
337 |
-
val_evaluator = dict(
|
338 |
-
type='mmdet.CocoMetric',
|
339 |
-
proposal_nums=(100, 1, 10),
|
340 |
-
ann_file=data_root + val_ann_file,
|
341 |
-
metric='bbox')
|
342 |
-
|
343 |
-
test_dataloader = dict(
|
344 |
-
dataset=dict(
|
345 |
-
metainfo=metainfo,
|
346 |
-
data_root=data_root,
|
347 |
-
ann_file=test_ann_file,
|
348 |
-
data_prefix=dict(img=test_data_prefix)))
|
349 |
-
test_evaluator = dict(
|
350 |
-
type='mmdet.CocoMetric',
|
351 |
-
proposal_nums=(100, 1, 10),
|
352 |
-
ann_file=data_root + test_ann_file,
|
353 |
-
metric='bbox')
|
354 |
-
|
355 |
-
train_cfg = dict(
|
356 |
-
type='EpochBasedTrainLoop',
|
357 |
-
max_epochs=max_epochs,
|
358 |
-
val_interval=save_epoch_intervals,
|
359 |
-
dynamic_intervals=[(max_epochs - num_epoch_stage2, val_interval_stage2)])
|
360 |
-
val_cfg = dict(type='ValLoop')
|
361 |
-
test_cfg = dict(type='TestLoop')
|
362 |
-
|
363 |
-
param_scheduler = None
|
364 |
-
optim_wrapper = dict(
|
365 |
-
type='OptimWrapper',
|
366 |
-
optimizer=dict(
|
367 |
-
type='SGD',
|
368 |
-
lr=base_lr,
|
369 |
-
momentum=0.937,
|
370 |
-
weight_decay=weight_decay,
|
371 |
-
nesterov=True,
|
372 |
-
batch_size_per_gpu=train_batch_size_per_gpu),
|
373 |
-
constructor='YOLOv7OptimWrapperConstructor')
|
374 |
-
|
375 |
-
# TO DO: change param_scheduler type to StepLR, refer to mobilenet
|
376 |
-
default_scope = 'mmyolo'
|
377 |
-
default_hooks = dict(
|
378 |
-
timer=dict(type='IterTimerHook'),
|
379 |
-
logger=dict(type='LoggerHook', interval=10),
|
380 |
-
param_scheduler=dict(
|
381 |
-
type='YOLOv5ParamSchedulerHook',
|
382 |
-
scheduler_type='cosine',
|
383 |
-
lr_factor=lr_factor, # note
|
384 |
-
max_epochs=max_epochs),
|
385 |
-
checkpoint=dict(
|
386 |
-
type='CheckpointHook',
|
387 |
-
save_param_scheduler=False,
|
388 |
-
interval=save_epoch_intervals,
|
389 |
-
save_best='auto',
|
390 |
-
max_keep_ckpts=max_keep_ckpts),
|
391 |
-
sampler_seed=dict(type='DistSamplerSeedHook'),
|
392 |
-
visualization=dict(type='mmdet.DetVisualizationHook'))
|
393 |
-
|
394 |
-
custom_hooks = [
|
395 |
-
dict(
|
396 |
-
type='EMAHook',
|
397 |
-
ema_type='ExpMomentumEMA',
|
398 |
-
momentum=0.001,
|
399 |
-
update_buffers=True,
|
400 |
-
strict_load=False,
|
401 |
-
priority=49)
|
402 |
-
]
|
403 |
-
|
404 |
-
# ============================
|
405 |
-
|
406 |
-
file_client_args = dict(backend='disk')
|
407 |
-
_file_client_args = dict(backend='disk')
|
408 |
-
tta_model = dict(
|
409 |
-
type='mmdet.DetTTAModel',
|
410 |
-
tta_cfg=dict(nms=dict(type='nms', iou_threshold=0.65), max_per_img=300))
|
411 |
-
img_scales = [
|
412 |
-
(
|
413 |
-
640,
|
414 |
-
640,
|
415 |
-
),
|
416 |
-
(
|
417 |
-
320,
|
418 |
-
320,
|
419 |
-
),
|
420 |
-
(
|
421 |
-
960,
|
422 |
-
960,
|
423 |
-
),
|
424 |
-
]
|
425 |
-
_multiscale_resize_transforms = [
|
426 |
-
dict(
|
427 |
-
type='Compose',
|
428 |
-
transforms=[
|
429 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
430 |
-
640,
|
431 |
-
640,
|
432 |
-
)),
|
433 |
-
dict(
|
434 |
-
type='LetterResize',
|
435 |
-
scale=(
|
436 |
-
640,
|
437 |
-
640,
|
438 |
-
),
|
439 |
-
allow_scale_up=False,
|
440 |
-
pad_val=dict(img=114)),
|
441 |
-
]),
|
442 |
-
dict(
|
443 |
-
type='Compose',
|
444 |
-
transforms=[
|
445 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
446 |
-
320,
|
447 |
-
320,
|
448 |
-
)),
|
449 |
-
dict(
|
450 |
-
type='LetterResize',
|
451 |
-
scale=(
|
452 |
-
320,
|
453 |
-
320,
|
454 |
-
),
|
455 |
-
allow_scale_up=False,
|
456 |
-
pad_val=dict(img=114)),
|
457 |
-
]),
|
458 |
-
dict(
|
459 |
-
type='Compose',
|
460 |
-
transforms=[
|
461 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
462 |
-
960,
|
463 |
-
960,
|
464 |
-
)),
|
465 |
-
dict(
|
466 |
-
type='LetterResize',
|
467 |
-
scale=(
|
468 |
-
960,
|
469 |
-
960,
|
470 |
-
),
|
471 |
-
allow_scale_up=False,
|
472 |
-
pad_val=dict(img=114)),
|
473 |
-
]),
|
474 |
-
]
|
475 |
-
tta_pipeline = [
|
476 |
-
dict(type='LoadImageFromFile', file_client_args=dict(backend='disk')),
|
477 |
-
dict(
|
478 |
-
type='TestTimeAug',
|
479 |
-
transforms=[
|
480 |
-
[
|
481 |
-
dict(
|
482 |
-
type='Compose',
|
483 |
-
transforms=[
|
484 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
485 |
-
640,
|
486 |
-
640,
|
487 |
-
)),
|
488 |
-
dict(
|
489 |
-
type='LetterResize',
|
490 |
-
scale=(
|
491 |
-
640,
|
492 |
-
640,
|
493 |
-
),
|
494 |
-
allow_scale_up=False,
|
495 |
-
pad_val=dict(img=114)),
|
496 |
-
]),
|
497 |
-
dict(
|
498 |
-
type='Compose',
|
499 |
-
transforms=[
|
500 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
501 |
-
320,
|
502 |
-
320,
|
503 |
-
)),
|
504 |
-
dict(
|
505 |
-
type='LetterResize',
|
506 |
-
scale=(
|
507 |
-
320,
|
508 |
-
320,
|
509 |
-
),
|
510 |
-
allow_scale_up=False,
|
511 |
-
pad_val=dict(img=114)),
|
512 |
-
]),
|
513 |
-
dict(
|
514 |
-
type='Compose',
|
515 |
-
transforms=[
|
516 |
-
dict(type='YOLOv5KeepRatioResize', scale=(
|
517 |
-
960,
|
518 |
-
960,
|
519 |
-
)),
|
520 |
-
dict(
|
521 |
-
type='LetterResize',
|
522 |
-
scale=(
|
523 |
-
960,
|
524 |
-
960,
|
525 |
-
),
|
526 |
-
allow_scale_up=False,
|
527 |
-
pad_val=dict(img=114)),
|
528 |
-
]),
|
529 |
-
],
|
530 |
-
[
|
531 |
-
dict(type='mmdet.RandomFlip', prob=1.0),
|
532 |
-
dict(type='mmdet.RandomFlip', prob=0.0),
|
533 |
-
],
|
534 |
-
[
|
535 |
-
dict(type='mmdet.LoadAnnotations', with_bbox=True),
|
536 |
-
],
|
537 |
-
[
|
538 |
-
dict(
|
539 |
-
type='mmdet.PackDetInputs',
|
540 |
-
meta_keys=(
|
541 |
-
'img_id',
|
542 |
-
'img_path',
|
543 |
-
'ori_shape',
|
544 |
-
'img_shape',
|
545 |
-
'scale_factor',
|
546 |
-
'pad_param',
|
547 |
-
'flip',
|
548 |
-
'flip_direction',
|
549 |
-
)),
|
550 |
-
],
|
551 |
-
]),
|
552 |
-
]
|
553 |
-
|
554 |
-
launcher = 'none'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AchyuthGamer/text-to-speech-client/assets/index-77d0c996.js
DELETED
The diff for this file is too large to render.
See raw diff
|
|
spaces/AgentVerse/agentVerse/ui/src/phaser3-rex-plugins/templates/ui/maker/Make.d.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
import Builders from './builders/Builders';
|
2 |
-
export default Make;
|
3 |
-
|
4 |
-
declare namespace Make {
|
5 |
-
type BuilderType = Builders.BuilderType;
|
6 |
-
type BuildersType = { [name: string]: BuilderType }
|
7 |
-
}
|
8 |
-
|
9 |
-
declare function Make(
|
10 |
-
scene: Phaser.Scene,
|
11 |
-
data: Object,
|
12 |
-
view?: Object,
|
13 |
-
styles?: Object,
|
14 |
-
customBuilders?: Make.BuildersType
|
15 |
-
): Phaser.GameObjects.GameObject;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AhmadHakami/Alzheimer_image_classification/README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Alzheimer Image Classification
|
3 |
-
emoji: ⚡
|
4 |
-
colorFrom: pink
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.40.1
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AiPalsDev/Translate_It/app.py
DELETED
@@ -1,82 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import MarianMTModel, MarianTokenizer, GPT2LMHeadModel, GPT2Tokenizer, AutoTokenizer, AutoModelForSequenceClassification
|
3 |
-
import torch
|
4 |
-
|
5 |
-
# Translation
|
6 |
-
def translate(text, target_language):
|
7 |
-
language_codes = {
|
8 |
-
"Spanish": "es",
|
9 |
-
"French (European)": "fr",
|
10 |
-
"French (Canadian)": "fr",
|
11 |
-
"Italian": "it",
|
12 |
-
"Ukrainian": "uk",
|
13 |
-
"Portuguese (Brazilian)": "pt_BR",
|
14 |
-
"Portuguese (European)": "pt",
|
15 |
-
"Russian": "ru",
|
16 |
-
"Chinese": "zh",
|
17 |
-
"Dutch": "nl",
|
18 |
-
"German": "de",
|
19 |
-
"Arabic": "ar",
|
20 |
-
"Hebrew": "he",
|
21 |
-
"Greek": "el"
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
# Text Generation
|
26 |
-
def generate_text(prompt):
|
27 |
-
text_gen = pipeline("text-generation", model="gpt2")
|
28 |
-
generated_text = text_gen(prompt, max_length=max_length, do_sample=True)[0]["generated_text"]
|
29 |
-
return generated_text
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
# Text Classification
|
35 |
-
def classify_text(text):
|
36 |
-
classifier = pipeline("zero-shot-classification")
|
37 |
-
result = classifier(text, labels.split(','))
|
38 |
-
scores = result["scores"]
|
39 |
-
predictions = result["labels"]
|
40 |
-
sorted_predictions = [pred for _, pred in sorted(zip(scores, predictions), reverse=True)]
|
41 |
-
return sorted_predictions
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
# Sentiment Analysis
|
46 |
-
def sentiment_analysis(text):
|
47 |
-
model_name = "distilbert-base-uncased-finetuned-sst-2-english"
|
48 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
49 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
50 |
-
inputs = tokenizer(text, return_tensors="pt")
|
51 |
-
outputs = model(**inputs)
|
52 |
-
sentiment_scores = torch.softmax(outputs.logits, dim=1)
|
53 |
-
sentiment = "positive" if sentiment_scores[0, 1] > sentiment_scores[0, 0] else "negative"
|
54 |
-
return sentiment
|
55 |
-
|
56 |
-
language_options = [
|
57 |
-
"Spanish", "French (European)", "French (Canadian)", "Italian", "Ukrainian",
|
58 |
-
"Portuguese (Brazilian)", "Portuguese (European)", "Russian", "Chinese",
|
59 |
-
"Dutch", "German", "Arabic", "Hebrew", "Greek"
|
60 |
-
]
|
61 |
-
|
62 |
-
iface = gr.Interface(
|
63 |
-
[translate, generate_text, classify_text, sentiment_analysis],
|
64 |
-
inputs=[
|
65 |
-
gr.inputs.Textbox(lines=5, label="Enter text to translate:"),
|
66 |
-
gr.inputs.Dropdown(choices=language_options, label="Target Language"),
|
67 |
-
gr.inputs.Textbox(lines=5, label="Enter text for text generation:"),
|
68 |
-
gr.inputs.Textbox(lines=5, label="Enter text for text classification:"),
|
69 |
-
gr.inputs.Textbox(lines=5, label="Enter text for sentiment analysis:"),
|
70 |
-
],
|
71 |
-
outputs=[
|
72 |
-
gr.outputs.Textbox(label="Translated Text"),
|
73 |
-
gr.outputs.Textbox(label="Generated Text"),
|
74 |
-
gr.outputs.Textbox(label="Classification Result"),
|
75 |
-
gr.outputs.Textbox(label="Sentiment Result"),
|
76 |
-
],
|
77 |
-
)
|
78 |
-
|
79 |
-
iface.launch()
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AlekseyKorshuk/gai-project/modules/common.py
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import config
|
3 |
-
from modules import utils
|
4 |
-
|
5 |
-
from modules.models import GuanacoModel, ChaiBot
|
6 |
-
|
7 |
-
|
8 |
-
def render_section_separator(title):
|
9 |
-
with gr.Row():
|
10 |
-
gr.Markdown(f"## {title}")
|
11 |
-
|
12 |
-
|
13 |
-
def render_model_selector():
|
14 |
-
model_ids = list(config.MODELS.keys())
|
15 |
-
model_tag = gr.Dropdown(
|
16 |
-
model_ids,
|
17 |
-
value=model_ids[0],
|
18 |
-
allow_custom_values=False,
|
19 |
-
label="Model ID",
|
20 |
-
info="Select a model to chat with.",
|
21 |
-
interactive=True
|
22 |
-
)
|
23 |
-
return model_tag
|
24 |
-
|
25 |
-
|
26 |
-
def render_bot_profile(bot_config):
|
27 |
-
with gr.Row():
|
28 |
-
with gr.Column():
|
29 |
-
bot_profile = _render_bot_profile_picture(bot_config)
|
30 |
-
with gr.Column():
|
31 |
-
bot_selector = _render_bot_selector()
|
32 |
-
return bot_profile, bot_selector
|
33 |
-
|
34 |
-
|
35 |
-
def _render_bot_profile_picture(bot_config):
|
36 |
-
bot_profile = gr.HTML(utils.get_bot_picture_html(bot_config))
|
37 |
-
return bot_profile
|
38 |
-
|
39 |
-
|
40 |
-
def _render_bot_selector():
|
41 |
-
bot_names = utils.get_bot_names()
|
42 |
-
dropdown = gr.Dropdown(
|
43 |
-
bot_names,
|
44 |
-
value=config.DEFAULT_BOT_NAME,
|
45 |
-
allow_custom_values=False,
|
46 |
-
label="Bot Name",
|
47 |
-
info="Select a bot to chat with.",
|
48 |
-
)
|
49 |
-
return dropdown
|
50 |
-
|
51 |
-
|
52 |
-
def render_bot_config(bot_config):
|
53 |
-
with gr.Accordion("Bot configuration:", open=False):
|
54 |
-
bot_config_text = gr.Markdown(
|
55 |
-
f"# Memory\n{bot_config.get('memory', '')}\n# Prompt\n{bot_config.get('prompt', '')}")
|
56 |
-
return bot_config_text
|
57 |
-
|
58 |
-
|
59 |
-
def render_chat_buttons():
|
60 |
-
with gr.Row():
|
61 |
-
msg = gr.Textbox(placeholder="Enter a message!")
|
62 |
-
send = gr.Button("Send")
|
63 |
-
regenerate = gr.Button("Regenerate")
|
64 |
-
with gr.Row():
|
65 |
-
clear = gr.Button("New conversation")
|
66 |
-
return msg, send, regenerate, clear
|
67 |
-
|
68 |
-
|
69 |
-
def get_convo_state(bot_config):
|
70 |
-
bot = ChaiBot(bot_config)
|
71 |
-
return gr.State(bot)
|
72 |
-
|
73 |
-
|
74 |
-
def get_model_state(model_config):
|
75 |
-
model = GuanacoModel(model_config)
|
76 |
-
return gr.State(model)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Alican/pixera/util/html.py
DELETED
@@ -1,86 +0,0 @@
|
|
1 |
-
import dominate
|
2 |
-
from dominate.tags import meta, h3, table, tr, td, p, a, img, br
|
3 |
-
import os
|
4 |
-
|
5 |
-
|
6 |
-
class HTML:
|
7 |
-
"""This HTML class allows us to save images and write texts into a single HTML file.
|
8 |
-
|
9 |
-
It consists of functions such as <add_header> (add a text header to the HTML file),
|
10 |
-
<add_images> (add a row of images to the HTML file), and <save> (save the HTML to the disk).
|
11 |
-
It is based on Python library 'dominate', a Python library for creating and manipulating HTML documents using a DOM API.
|
12 |
-
"""
|
13 |
-
|
14 |
-
def __init__(self, web_dir, title, refresh=0):
|
15 |
-
"""Initialize the HTML classes
|
16 |
-
|
17 |
-
Parameters:
|
18 |
-
web_dir (str) -- a directory that stores the webpage. HTML file will be created at <web_dir>/index.html; images will be saved at <web_dir/images/
|
19 |
-
title (str) -- the webpage name
|
20 |
-
refresh (int) -- how often the website refresh itself; if 0; no refreshing
|
21 |
-
"""
|
22 |
-
self.title = title
|
23 |
-
self.web_dir = web_dir
|
24 |
-
self.img_dir = os.path.join(self.web_dir, 'images')
|
25 |
-
if not os.path.exists(self.web_dir):
|
26 |
-
os.makedirs(self.web_dir)
|
27 |
-
if not os.path.exists(self.img_dir):
|
28 |
-
os.makedirs(self.img_dir)
|
29 |
-
|
30 |
-
self.doc = dominate.document(title=title)
|
31 |
-
if refresh > 0:
|
32 |
-
with self.doc.head:
|
33 |
-
meta(http_equiv="refresh", content=str(refresh))
|
34 |
-
|
35 |
-
def get_image_dir(self):
|
36 |
-
"""Return the directory that stores images"""
|
37 |
-
return self.img_dir
|
38 |
-
|
39 |
-
def add_header(self, text):
|
40 |
-
"""Insert a header to the HTML file
|
41 |
-
|
42 |
-
Parameters:
|
43 |
-
text (str) -- the header text
|
44 |
-
"""
|
45 |
-
with self.doc:
|
46 |
-
h3(text)
|
47 |
-
|
48 |
-
def add_images(self, ims, txts, links, width=400):
|
49 |
-
"""add images to the HTML file
|
50 |
-
|
51 |
-
Parameters:
|
52 |
-
ims (str list) -- a list of image paths
|
53 |
-
txts (str list) -- a list of image names shown on the website
|
54 |
-
links (str list) -- a list of hyperref links; when you click an image, it will redirect you to a new page
|
55 |
-
"""
|
56 |
-
self.t = table(border=1, style="table-layout: fixed;") # Insert a table
|
57 |
-
self.doc.add(self.t)
|
58 |
-
with self.t:
|
59 |
-
with tr():
|
60 |
-
for im, txt, link in zip(ims, txts, links):
|
61 |
-
with td(style="word-wrap: break-word;", halign="center", valign="top"):
|
62 |
-
with p():
|
63 |
-
with a(href=os.path.join('images', link)):
|
64 |
-
img(style="width:%dpx" % width, src=os.path.join('images', im))
|
65 |
-
br()
|
66 |
-
p(txt)
|
67 |
-
|
68 |
-
def save(self):
|
69 |
-
"""save the current content to the HMTL file"""
|
70 |
-
html_file = '%s/index.html' % self.web_dir
|
71 |
-
f = open(html_file, 'wt')
|
72 |
-
f.write(self.doc.render())
|
73 |
-
f.close()
|
74 |
-
|
75 |
-
|
76 |
-
if __name__ == '__main__': # we show an example usage here.
|
77 |
-
html = HTML('web/', 'test_html')
|
78 |
-
html.add_header('hello world')
|
79 |
-
|
80 |
-
ims, txts, links = [], [], []
|
81 |
-
for n in range(4):
|
82 |
-
ims.append('image_%d.png' % n)
|
83 |
-
txts.append('text_%d' % n)
|
84 |
-
links.append('image_%d.png' % n)
|
85 |
-
html.add_images(ims, txts, links)
|
86 |
-
html.save()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Alpaca233/SadTalker/src/audio2pose_models/audio2pose.py
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
from torch import nn
|
3 |
-
from src.audio2pose_models.cvae import CVAE
|
4 |
-
from src.audio2pose_models.discriminator import PoseSequenceDiscriminator
|
5 |
-
from src.audio2pose_models.audio_encoder import AudioEncoder
|
6 |
-
|
7 |
-
class Audio2Pose(nn.Module):
|
8 |
-
def __init__(self, cfg, wav2lip_checkpoint, device='cuda'):
|
9 |
-
super().__init__()
|
10 |
-
self.cfg = cfg
|
11 |
-
self.seq_len = cfg.MODEL.CVAE.SEQ_LEN
|
12 |
-
self.latent_dim = cfg.MODEL.CVAE.LATENT_SIZE
|
13 |
-
self.device = device
|
14 |
-
|
15 |
-
self.audio_encoder = AudioEncoder(wav2lip_checkpoint, device)
|
16 |
-
self.audio_encoder.eval()
|
17 |
-
for param in self.audio_encoder.parameters():
|
18 |
-
param.requires_grad = False
|
19 |
-
|
20 |
-
self.netG = CVAE(cfg)
|
21 |
-
self.netD_motion = PoseSequenceDiscriminator(cfg)
|
22 |
-
|
23 |
-
|
24 |
-
def forward(self, x):
|
25 |
-
|
26 |
-
batch = {}
|
27 |
-
coeff_gt = x['gt'].cuda().squeeze(0) #bs frame_len+1 73
|
28 |
-
batch['pose_motion_gt'] = coeff_gt[:, 1:, 64:70] - coeff_gt[:, :1, 64:70] #bs frame_len 6
|
29 |
-
batch['ref'] = coeff_gt[:, 0, 64:70] #bs 6
|
30 |
-
batch['class'] = x['class'].squeeze(0).cuda() # bs
|
31 |
-
indiv_mels= x['indiv_mels'].cuda().squeeze(0) # bs seq_len+1 80 16
|
32 |
-
|
33 |
-
# forward
|
34 |
-
audio_emb_list = []
|
35 |
-
audio_emb = self.audio_encoder(indiv_mels[:, 1:, :, :].unsqueeze(2)) #bs seq_len 512
|
36 |
-
batch['audio_emb'] = audio_emb
|
37 |
-
batch = self.netG(batch)
|
38 |
-
|
39 |
-
pose_motion_pred = batch['pose_motion_pred'] # bs frame_len 6
|
40 |
-
pose_gt = coeff_gt[:, 1:, 64:70].clone() # bs frame_len 6
|
41 |
-
pose_pred = coeff_gt[:, :1, 64:70] + pose_motion_pred # bs frame_len 6
|
42 |
-
|
43 |
-
batch['pose_pred'] = pose_pred
|
44 |
-
batch['pose_gt'] = pose_gt
|
45 |
-
|
46 |
-
return batch
|
47 |
-
|
48 |
-
def test(self, x):
|
49 |
-
|
50 |
-
batch = {}
|
51 |
-
ref = x['ref'] #bs 1 70
|
52 |
-
batch['ref'] = x['ref'][:,0,-6:]
|
53 |
-
batch['class'] = x['class']
|
54 |
-
bs = ref.shape[0]
|
55 |
-
|
56 |
-
indiv_mels= x['indiv_mels'] # bs T 1 80 16
|
57 |
-
indiv_mels_use = indiv_mels[:, 1:] # we regard the ref as the first frame
|
58 |
-
num_frames = x['num_frames']
|
59 |
-
num_frames = int(num_frames) - 1
|
60 |
-
|
61 |
-
#
|
62 |
-
div = num_frames//self.seq_len
|
63 |
-
re = num_frames%self.seq_len
|
64 |
-
audio_emb_list = []
|
65 |
-
pose_motion_pred_list = [torch.zeros(batch['ref'].unsqueeze(1).shape, dtype=batch['ref'].dtype,
|
66 |
-
device=batch['ref'].device)]
|
67 |
-
|
68 |
-
for i in range(div):
|
69 |
-
z = torch.randn(bs, self.latent_dim).to(ref.device)
|
70 |
-
batch['z'] = z
|
71 |
-
audio_emb = self.audio_encoder(indiv_mels_use[:, i*self.seq_len:(i+1)*self.seq_len,:,:,:]) #bs seq_len 512
|
72 |
-
batch['audio_emb'] = audio_emb
|
73 |
-
batch = self.netG.test(batch)
|
74 |
-
pose_motion_pred_list.append(batch['pose_motion_pred']) #list of bs seq_len 6
|
75 |
-
|
76 |
-
if re != 0:
|
77 |
-
z = torch.randn(bs, self.latent_dim).to(ref.device)
|
78 |
-
batch['z'] = z
|
79 |
-
audio_emb = self.audio_encoder(indiv_mels_use[:, -1*self.seq_len:,:,:,:]) #bs seq_len 512
|
80 |
-
if audio_emb.shape[1] != self.seq_len:
|
81 |
-
pad_dim = self.seq_len-audio_emb.shape[1]
|
82 |
-
pad_audio_emb = audio_emb[:, :1].repeat(1, pad_dim, 1)
|
83 |
-
audio_emb = torch.cat([pad_audio_emb, audio_emb], 1)
|
84 |
-
batch['audio_emb'] = audio_emb
|
85 |
-
batch = self.netG.test(batch)
|
86 |
-
pose_motion_pred_list.append(batch['pose_motion_pred'][:,-1*re:,:])
|
87 |
-
|
88 |
-
pose_motion_pred = torch.cat(pose_motion_pred_list, dim = 1)
|
89 |
-
batch['pose_motion_pred'] = pose_motion_pred
|
90 |
-
|
91 |
-
pose_pred = ref[:, :1, -6:] + pose_motion_pred # bs T 6
|
92 |
-
|
93 |
-
batch['pose_pred'] = pose_pred
|
94 |
-
return batch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Andy1621/uniformerv2_demo/app.py
DELETED
@@ -1,131 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
|
3 |
-
import torch
|
4 |
-
import torch.nn as nn
|
5 |
-
import numpy as np
|
6 |
-
import torch.nn.functional as F
|
7 |
-
import torchvision.transforms as T
|
8 |
-
from PIL import Image
|
9 |
-
from decord import VideoReader
|
10 |
-
from decord import cpu
|
11 |
-
from uniformerv2 import uniformerv2_b16
|
12 |
-
from kinetics_class_index import kinetics_classnames
|
13 |
-
from transforms import (
|
14 |
-
GroupNormalize, GroupScale, GroupCenterCrop,
|
15 |
-
Stack, ToTorchFormatTensor
|
16 |
-
)
|
17 |
-
|
18 |
-
import gradio as gr
|
19 |
-
from huggingface_hub import hf_hub_download
|
20 |
-
|
21 |
-
class Uniformerv2(nn.Module):
|
22 |
-
def __init__(self, model):
|
23 |
-
super().__init__()
|
24 |
-
self.backbone = model
|
25 |
-
|
26 |
-
def forward(self, x):
|
27 |
-
return self.backbone(x)
|
28 |
-
|
29 |
-
# Device on which to run the model
|
30 |
-
# Set to cuda to load on GPU
|
31 |
-
device = "cpu"
|
32 |
-
model_path = hf_hub_download(repo_id="Andy1621/uniformerv2", filename="k400+k710_uniformerv2_b16_8x224.pyth")
|
33 |
-
# Pick a pretrained model
|
34 |
-
model = Uniformerv2(uniformerv2_b16(pretrained=False, t_size=8, no_lmhra=True, temporal_downsample=False))
|
35 |
-
state_dict = torch.load(model_path, map_location='cpu')
|
36 |
-
model.load_state_dict(state_dict)
|
37 |
-
|
38 |
-
# Set to eval mode and move to desired device
|
39 |
-
model = model.to(device)
|
40 |
-
model = model.eval()
|
41 |
-
|
42 |
-
# Create an id to label name mapping
|
43 |
-
kinetics_id_to_classname = {}
|
44 |
-
for k, v in kinetics_classnames.items():
|
45 |
-
kinetics_id_to_classname[k] = v
|
46 |
-
|
47 |
-
|
48 |
-
def get_index(num_frames, num_segments=8):
|
49 |
-
seg_size = float(num_frames - 1) / num_segments
|
50 |
-
start = int(seg_size / 2)
|
51 |
-
offsets = np.array([
|
52 |
-
start + int(np.round(seg_size * idx)) for idx in range(num_segments)
|
53 |
-
])
|
54 |
-
return offsets
|
55 |
-
|
56 |
-
|
57 |
-
def load_video(video_path):
|
58 |
-
vr = VideoReader(video_path, ctx=cpu(0))
|
59 |
-
num_frames = len(vr)
|
60 |
-
frame_indices = get_index(num_frames, 8)
|
61 |
-
|
62 |
-
# transform
|
63 |
-
crop_size = 224
|
64 |
-
scale_size = 256
|
65 |
-
input_mean = [0.485, 0.456, 0.406]
|
66 |
-
input_std = [0.229, 0.224, 0.225]
|
67 |
-
|
68 |
-
transform = T.Compose([
|
69 |
-
GroupScale(int(scale_size)),
|
70 |
-
GroupCenterCrop(crop_size),
|
71 |
-
Stack(),
|
72 |
-
ToTorchFormatTensor(),
|
73 |
-
GroupNormalize(input_mean, input_std)
|
74 |
-
])
|
75 |
-
|
76 |
-
images_group = list()
|
77 |
-
for frame_index in frame_indices:
|
78 |
-
img = Image.fromarray(vr[frame_index].asnumpy())
|
79 |
-
images_group.append(img)
|
80 |
-
torch_imgs = transform(images_group)
|
81 |
-
return torch_imgs
|
82 |
-
|
83 |
-
|
84 |
-
def inference(video):
|
85 |
-
vid = load_video(video)
|
86 |
-
|
87 |
-
# The model expects inputs of shape: B x C x H x W
|
88 |
-
TC, H, W = vid.shape
|
89 |
-
inputs = vid.reshape(1, TC//3, 3, H, W).permute(0, 2, 1, 3, 4)
|
90 |
-
|
91 |
-
prediction = model(inputs)
|
92 |
-
prediction = F.softmax(prediction, dim=1).flatten()
|
93 |
-
|
94 |
-
return {kinetics_id_to_classname[str(i)]: float(prediction[i]) for i in range(400)}
|
95 |
-
|
96 |
-
|
97 |
-
def set_example_video(example: list) -> dict:
|
98 |
-
return gr.Video.update(value=example[0])
|
99 |
-
|
100 |
-
|
101 |
-
demo = gr.Blocks()
|
102 |
-
with demo:
|
103 |
-
gr.Markdown(
|
104 |
-
"""
|
105 |
-
# UniFormerV2-B
|
106 |
-
Gradio demo for <a href='https://github.com/OpenGVLab/UniFormerV2' target='_blank'>UniFormerV2</a>: To use it, simply upload your video, or click one of the examples to load them. Read more at the links below.
|
107 |
-
"""
|
108 |
-
)
|
109 |
-
|
110 |
-
with gr.Box():
|
111 |
-
with gr.Row():
|
112 |
-
with gr.Column():
|
113 |
-
with gr.Row():
|
114 |
-
input_video = gr.Video(label='Input Video')
|
115 |
-
with gr.Row():
|
116 |
-
submit_button = gr.Button('Submit')
|
117 |
-
with gr.Column():
|
118 |
-
label = gr.Label(num_top_classes=5)
|
119 |
-
with gr.Row():
|
120 |
-
example_videos = gr.Dataset(components=[input_video], samples=[['hitting_baseball.mp4'], ['hoverboarding.mp4'], ['yoga.mp4']])
|
121 |
-
|
122 |
-
gr.Markdown(
|
123 |
-
"""
|
124 |
-
<p style='text-align: center'><a href='https://arxiv.org/abs/2211.09552' target='_blank'>[Arxiv] UniFormerV2: Spatiotemporal Learning by Arming Image ViTs with Video UniFormer</a> | <a href='https://github.com/OpenGVLab/UniFormerV2' target='_blank'>Github Repo</a></p>
|
125 |
-
"""
|
126 |
-
)
|
127 |
-
|
128 |
-
submit_button.click(fn=inference, inputs=input_video, outputs=label)
|
129 |
-
example_videos.click(fn=set_example_video, inputs=example_videos, outputs=example_videos.components)
|
130 |
-
|
131 |
-
demo.launch(enable_queue=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/AnkitGaur2811/Image_Conversion_app_using_Opencv/app.py
DELETED
@@ -1,191 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""Image Conversion App .ipynb
|
3 |
-
|
4 |
-
Automatically generated by Colaboratory.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1GA79rJr1_J5bHa7sWxF1GtDqqaTznVia
|
8 |
-
|
9 |
-
# ***Image Conversion from Simple image***
|
10 |
-
> To
|
11 |
-
1. Edge Image
|
12 |
-
2. Pencile sketch
|
13 |
-
3. Painting
|
14 |
-
4. Cartoon image
|
15 |
-
|
16 |
-
###Step 1:- Import All libraries
|
17 |
-
Namely
|
18 |
-
- Numpy (For storing Image)
|
19 |
-
- Matplotlib (For Display image)
|
20 |
-
- OpenCV (for Converting the image)
|
21 |
-
"""
|
22 |
-
|
23 |
-
# installing all imp libs to the machine
|
24 |
-
#!pip install opencv_contrib_python
|
25 |
-
|
26 |
-
import cv2
|
27 |
-
import numpy as np
|
28 |
-
import matplotlib.pyplot as plt
|
29 |
-
import gradio as gr
|
30 |
-
|
31 |
-
"""###Step 2:- Import and show the image
|
32 |
-
for this we will be using opencv and matplotlib
|
33 |
-
|
34 |
-
"""
|
35 |
-
|
36 |
-
def read_image(Image):
|
37 |
-
'''
|
38 |
-
This Function is made to take image input from the user
|
39 |
-
Input: Path of the Image
|
40 |
-
Output: Image in RGB format
|
41 |
-
'''
|
42 |
-
img = cv2.imread(Image)
|
43 |
-
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) # As opencv read the image as BGR so we have to convert it to RGB
|
44 |
-
plt.imshow(img)
|
45 |
-
plt.show()
|
46 |
-
return img
|
47 |
-
|
48 |
-
#filename ="/content/to.jpeg"
|
49 |
-
#Image= read_image(filename)
|
50 |
-
|
51 |
-
"""### Step 3:- Converting the Image to respective types
|
52 |
-
Making diffrent Function for each work
|
53 |
-
|
54 |
-
####4. Cartoon Image
|
55 |
-
"""
|
56 |
-
|
57 |
-
# create Edge
|
58 |
-
def edge_mask(Image, line_size, Blur_value):
|
59 |
-
grey_img=cv2.cvtColor(Image,cv2.COLOR_RGB2GRAY)
|
60 |
-
grey_blur= cv2.medianBlur(grey_img, Blur_value)
|
61 |
-
edge_image= cv2.adaptiveThreshold(grey_blur, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, line_size, Blur_value)
|
62 |
-
return edge_image
|
63 |
-
# line_size,Blur_value=7,7
|
64 |
-
# edges= edge_mask(Image,line_size,Blur_value)
|
65 |
-
# plt.imshow(edges, cmap="binary")
|
66 |
-
# plt.show()
|
67 |
-
|
68 |
-
#reduce Colour Palet
|
69 |
-
def colour_quantization(Image, k):
|
70 |
-
data=np.float32(Image).reshape(-1,3)
|
71 |
-
critria= (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 20, 0.01)
|
72 |
-
ret, label, center= cv2.kmeans(data,k, None, critria, 10, cv2.KMEANS_RANDOM_CENTERS)
|
73 |
-
centers= np.uint8(center)
|
74 |
-
result=centers[label.flatten()]
|
75 |
-
result=result.reshape(Image.shape)
|
76 |
-
return result
|
77 |
-
# Paint= colour_quantization(Image,10)
|
78 |
-
# plt.imshow(Paint)
|
79 |
-
# plt.show()
|
80 |
-
# cv2.imwrite("final1.jpg",Paint)
|
81 |
-
|
82 |
-
def cartoon(Paint,edges):
|
83 |
-
Blurred_img= cv2.bilateralFilter(Paint, d=8 ,sigmaColor=200, sigmaSpace=200)
|
84 |
-
Final=cv2.bitwise_and(Blurred_img,Blurred_img,mask=edges)
|
85 |
-
# plt.imshow(Final)
|
86 |
-
# plt.show()
|
87 |
-
# Final= cv2.cvtColor(Final, cv2.COLOR_RGB2BGR)
|
88 |
-
# cv2.imwrite("Final.jpg", Final)
|
89 |
-
return Final
|
90 |
-
# cartoon()
|
91 |
-
|
92 |
-
def Main_cartoon(Image,Line_size,Blur_value,Color_count):
|
93 |
-
edge_mask_img= edge_mask(Image, Line_size, Blur_value)
|
94 |
-
Paint_img=colour_quantization(Image, Color_count)
|
95 |
-
cartoon_img= cartoon(Paint_img,edge_mask_img)
|
96 |
-
# cartoon_img=cv2.cvtColor(cartoon_img, cv2.COLOR_RGB2BGR)
|
97 |
-
return cartoon_img
|
98 |
-
|
99 |
-
#x=Main_cartoon(Image,7,7,10)
|
100 |
-
|
101 |
-
"""####3. Painting"""
|
102 |
-
|
103 |
-
def Painting(Image, Colour_count):
|
104 |
-
Painting=colour_quantization(Image,Colour_count)
|
105 |
-
# Painting=cv2.cvtColor(Painting, cv2.COLOR_RGB2BGR)
|
106 |
-
return Painting
|
107 |
-
|
108 |
-
#y=Painting(Image,10)
|
109 |
-
|
110 |
-
"""####2.Pencil Sketch"""
|
111 |
-
|
112 |
-
def Pencil_sketch(Image):
|
113 |
-
grey_img=cv2.cvtColor(Image, cv2.COLOR_BGR2GRAY)
|
114 |
-
invert_img=cv2.bitwise_not(grey_img)
|
115 |
-
blur_img=cv2.GaussianBlur(invert_img, (111,111),0)
|
116 |
-
invblur_img=cv2.bitwise_not(blur_img)
|
117 |
-
sketch_img=cv2.divide(grey_img,invblur_img, scale=256.0)
|
118 |
-
return sketch_img
|
119 |
-
|
120 |
-
#z=Pencil_sketch(Image)
|
121 |
-
|
122 |
-
"""####1.Edge Sketch"""
|
123 |
-
|
124 |
-
def Edge_sketch(Image):
|
125 |
-
edge_img = cv2.Canny(Image,100,200)
|
126 |
-
edge_img = cv2.cvtColor(edge_img,cv2.COLOR_BGR2RGB)
|
127 |
-
return edge_img
|
128 |
-
|
129 |
-
#t=Edge_sketch(Image)
|
130 |
-
|
131 |
-
"""###Step 4:- Testing"""
|
132 |
-
|
133 |
-
#plt.imshow(x)
|
134 |
-
#plt.show()
|
135 |
-
#cv2.imwrite("Final.jpg", x)
|
136 |
-
|
137 |
-
#plt.imshow(y)
|
138 |
-
#plt.show()
|
139 |
-
#cv2.imwrite("final1.jpg",y)
|
140 |
-
|
141 |
-
#plt.imshow(z)
|
142 |
-
#plt.show()
|
143 |
-
#cv2.imwrite("final2.jpg",z)
|
144 |
-
|
145 |
-
#plt.imshow(t)
|
146 |
-
#plt.show()
|
147 |
-
#cv2.imwrite("final3.jpg",t)
|
148 |
-
|
149 |
-
"""### Step 5:- Gradio app and driver code
|
150 |
-
|
151 |
-
#### Driver Code
|
152 |
-
"""
|
153 |
-
|
154 |
-
def Sketch_app(Image,Type,Color_count,Line_size,Blur_value):
|
155 |
-
if Type == "Cartoon":
|
156 |
-
Result = Main_cartoon(Image,Line_size,Blur_value,Color_count)
|
157 |
-
elif Type == "Painting":
|
158 |
-
Result = Painting(Image,Color_count)
|
159 |
-
elif Type == "Pencil sketch":
|
160 |
-
Result = Pencil_sketch(Image)
|
161 |
-
else:
|
162 |
-
Result = None
|
163 |
-
return Result
|
164 |
-
|
165 |
-
"""#### Gradio app
|
166 |
-
|
167 |
-
##### Installing and Importing Gradio
|
168 |
-
As Gradio is a 3rd party library we have to install it in Our Run time before Executing
|
169 |
-
"""
|
170 |
-
|
171 |
-
#!pip install gradio
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
Image_conversion = gr.Interface(
|
176 |
-
fn = Sketch_app,
|
177 |
-
inputs=[
|
178 |
-
gr.Image( tool="select",label="Image to Convert", show_label=True),
|
179 |
-
gr.Dropdown( choices = ["Pencil sketch","Painting","Cartoon"],label="Type to convert", show_label=True),
|
180 |
-
gr.Slider( minimum=5, maximum=20, value =10, step= 1,label="Number of colour to be used in photo ( use only in case of painting and cartoon)", show_label=True),
|
181 |
-
gr.Slider( minimum=5, maximum=10, value =7, step= 2,label="Blurr effect to be used in photo ( use only in case of cartoon)", show_label=True),
|
182 |
-
gr.Slider( minimum=5, maximum=10, value =7, step= 2,label="Thickness of edges to be used in photo ( use only in case of cartoon)", show_label=True)],
|
183 |
-
outputs= "image",
|
184 |
-
tittle = " Image Conversion App",
|
185 |
-
description = """This is an image conversion app we take a regular photo and convert it into Cartoon, Painting, Pencil sketch. it is purely python based used
|
186 |
-
Gradio(for interfaceing), OpenCV (For image conversion), Numpy(for storing the image), Matplotlib (for displaying the image) """,
|
187 |
-
theme = "dark"
|
188 |
-
)
|
189 |
-
|
190 |
-
Image_conversion.launch(share=True)
|
191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Arielliu/just_talk/README.md
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Just Talk
|
3 |
-
emoji: 🏢
|
4 |
-
colorFrom: pink
|
5 |
-
colorTo: gray
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.28.2
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/ArtGAN/Diffusion-API/diffusion_webui/utils/data_utils.py
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
from PIL import Image
|
2 |
-
|
3 |
-
|
4 |
-
def image_grid(imgs, rows, cols):
|
5 |
-
assert len(imgs) == rows * cols
|
6 |
-
|
7 |
-
w, h = imgs[0].size
|
8 |
-
grid = Image.new("RGB", size=(cols * w, rows * h))
|
9 |
-
|
10 |
-
for i, img in enumerate(imgs):
|
11 |
-
grid.paste(img, box=(i % cols * w, i // cols * h))
|
12 |
-
return grid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Artrajz/vits-simple-api/bert_vits2/bert_vits2.py
DELETED
@@ -1,133 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
import torch
|
3 |
-
|
4 |
-
from bert_vits2 import commons
|
5 |
-
from bert_vits2 import utils as bert_vits2_utils
|
6 |
-
from bert_vits2.models import SynthesizerTrn
|
7 |
-
from bert_vits2.text import *
|
8 |
-
from bert_vits2.text.cleaner import clean_text
|
9 |
-
from bert_vits2.utils import process_legacy_versions
|
10 |
-
from contants import ModelType
|
11 |
-
from utils import classify_language, get_hparams_from_file, lang_dict
|
12 |
-
from utils.sentence import sentence_split_and_markup, cut
|
13 |
-
|
14 |
-
|
15 |
-
class Bert_VITS2:
|
16 |
-
def __init__(self, model, config, device=torch.device("cpu"), **kwargs):
|
17 |
-
self.hps_ms = get_hparams_from_file(config) if isinstance(config, str) else config
|
18 |
-
self.n_speakers = getattr(self.hps_ms.data, 'n_speakers', 0)
|
19 |
-
self.speakers = [item[0] for item in
|
20 |
-
sorted(list(getattr(self.hps_ms.data, 'spk2id', {'0': 0}).items()), key=lambda x: x[1])]
|
21 |
-
self.symbols = symbols
|
22 |
-
|
23 |
-
|
24 |
-
# Compatible with legacy versions
|
25 |
-
self.version = process_legacy_versions(self.hps_ms)
|
26 |
-
|
27 |
-
if self.version in ["1.0", "1.0.0", "1.0.1"]:
|
28 |
-
self.symbols = symbols_legacy
|
29 |
-
self.hps_ms.model.n_layers_trans_flow = 3
|
30 |
-
|
31 |
-
|
32 |
-
elif self.version in ["1.1.0-transition"]:
|
33 |
-
self.hps_ms.model.n_layers_trans_flow = 3
|
34 |
-
|
35 |
-
elif self.version in ["1.1", "1.1.0", "1.1.1"]:
|
36 |
-
self.hps_ms.model.n_layers_trans_flow = 6
|
37 |
-
|
38 |
-
key = f"{ModelType.BERT_VITS2.value}_v{self.version}" if self.version else ModelType.BERT_VITS2.value
|
39 |
-
self.lang = lang_dict.get(key, ["unknown"])
|
40 |
-
self.bert_handler = BertHandler(self.lang)
|
41 |
-
|
42 |
-
self._symbol_to_id = {s: i for i, s in enumerate(self.symbols)}
|
43 |
-
|
44 |
-
self.net_g = SynthesizerTrn(
|
45 |
-
len(self.symbols),
|
46 |
-
self.hps_ms.data.filter_length // 2 + 1,
|
47 |
-
self.hps_ms.train.segment_size // self.hps_ms.data.hop_length,
|
48 |
-
n_speakers=self.hps_ms.data.n_speakers,
|
49 |
-
symbols=self.symbols,
|
50 |
-
**self.hps_ms.model).to(device)
|
51 |
-
_ = self.net_g.eval()
|
52 |
-
self.device = device
|
53 |
-
self.load_model(model)
|
54 |
-
|
55 |
-
def load_model(self, model):
|
56 |
-
bert_vits2_utils.load_checkpoint(model, self.net_g, None, skip_optimizer=True, version=self.version)
|
57 |
-
|
58 |
-
def get_speakers(self):
|
59 |
-
return self.speakers
|
60 |
-
|
61 |
-
@property
|
62 |
-
def sampling_rate(self):
|
63 |
-
return self.hps_ms.data.sampling_rate
|
64 |
-
|
65 |
-
def get_text(self, text, language_str, hps):
|
66 |
-
norm_text, phone, tone, word2ph = clean_text(text, language_str)
|
67 |
-
phone, tone, language = cleaned_text_to_sequence(phone, tone, language_str, self._symbol_to_id)
|
68 |
-
|
69 |
-
if hps.data.add_blank:
|
70 |
-
phone = commons.intersperse(phone, 0)
|
71 |
-
tone = commons.intersperse(tone, 0)
|
72 |
-
language = commons.intersperse(language, 0)
|
73 |
-
for i in range(len(word2ph)):
|
74 |
-
word2ph[i] = word2ph[i] * 2
|
75 |
-
word2ph[0] += 1
|
76 |
-
bert = self.bert_handler.get_bert(norm_text, word2ph, language_str)
|
77 |
-
del word2ph
|
78 |
-
assert bert.shape[-1] == len(phone), phone
|
79 |
-
|
80 |
-
if language_str == "zh":
|
81 |
-
bert = bert
|
82 |
-
ja_bert = torch.zeros(768, len(phone))
|
83 |
-
elif language_str == "ja":
|
84 |
-
ja_bert = bert
|
85 |
-
bert = torch.zeros(1024, len(phone))
|
86 |
-
else:
|
87 |
-
bert = torch.zeros(1024, len(phone))
|
88 |
-
ja_bert = torch.zeros(768, len(phone))
|
89 |
-
assert bert.shape[-1] == len(
|
90 |
-
phone
|
91 |
-
), f"Bert seq len {bert.shape[-1]} != {len(phone)}"
|
92 |
-
phone = torch.LongTensor(phone)
|
93 |
-
tone = torch.LongTensor(tone)
|
94 |
-
language = torch.LongTensor(language)
|
95 |
-
return bert, ja_bert, phone, tone, language
|
96 |
-
|
97 |
-
def infer(self, text, lang, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid):
|
98 |
-
bert, ja_bert, phones, tones, lang_ids = self.get_text(text, lang, self.hps_ms)
|
99 |
-
with torch.no_grad():
|
100 |
-
x_tst = phones.to(self.device).unsqueeze(0)
|
101 |
-
tones = tones.to(self.device).unsqueeze(0)
|
102 |
-
lang_ids = lang_ids.to(self.device).unsqueeze(0)
|
103 |
-
bert = bert.to(self.device).unsqueeze(0)
|
104 |
-
ja_bert = ja_bert.to(self.device).unsqueeze(0)
|
105 |
-
x_tst_lengths = torch.LongTensor([phones.size(0)]).to(self.device)
|
106 |
-
speakers = torch.LongTensor([int(sid)]).to(self.device)
|
107 |
-
audio = self.net_g.infer(x_tst, x_tst_lengths, speakers, tones, lang_ids, bert, ja_bert, sdp_ratio=sdp_ratio
|
108 |
-
, noise_scale=noise_scale, noise_scale_w=noise_scale_w, length_scale=length_scale)[
|
109 |
-
0][0, 0].data.cpu().float().numpy()
|
110 |
-
|
111 |
-
torch.cuda.empty_cache()
|
112 |
-
return audio
|
113 |
-
|
114 |
-
def get_audio(self, voice, auto_break=False):
|
115 |
-
text = voice.get("text", None)
|
116 |
-
lang = voice.get("lang", "auto")
|
117 |
-
sdp_ratio = voice.get("sdp_ratio", 0.2)
|
118 |
-
noise_scale = voice.get("noise", 0.5)
|
119 |
-
noise_scale_w = voice.get("noisew", 0.6)
|
120 |
-
length_scale = voice.get("length", 1)
|
121 |
-
sid = voice.get("id", 0)
|
122 |
-
max = voice.get("max", 50)
|
123 |
-
# sentence_list = sentence_split_and_markup(text, max, "ZH", ["zh"])
|
124 |
-
if lang == "auto":
|
125 |
-
lang = classify_language(text, target_languages=self.lang)
|
126 |
-
|
127 |
-
sentence_list = cut(text, max)
|
128 |
-
audios = []
|
129 |
-
for sentence in sentence_list:
|
130 |
-
audio = self.infer(sentence, lang, sdp_ratio, noise_scale, noise_scale_w, length_scale, sid)
|
131 |
-
audios.append(audio)
|
132 |
-
audio = np.concatenate(audios)
|
133 |
-
return audio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/pip/_vendor/urllib3/packages/backports/__init__.py
DELETED
File without changes
|
spaces/Ataturk-Chatbot/HuggingFaceChat/venv/lib/python3.11/site-packages/setuptools/logging.py
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
import sys
|
2 |
-
import logging
|
3 |
-
import distutils.log
|
4 |
-
from . import monkey
|
5 |
-
|
6 |
-
|
7 |
-
def _not_warning(record):
|
8 |
-
return record.levelno < logging.WARNING
|
9 |
-
|
10 |
-
|
11 |
-
def configure():
|
12 |
-
"""
|
13 |
-
Configure logging to emit warning and above to stderr
|
14 |
-
and everything else to stdout. This behavior is provided
|
15 |
-
for compatibility with distutils.log but may change in
|
16 |
-
the future.
|
17 |
-
"""
|
18 |
-
err_handler = logging.StreamHandler()
|
19 |
-
err_handler.setLevel(logging.WARNING)
|
20 |
-
out_handler = logging.StreamHandler(sys.stdout)
|
21 |
-
out_handler.addFilter(_not_warning)
|
22 |
-
handlers = err_handler, out_handler
|
23 |
-
logging.basicConfig(
|
24 |
-
format="{message}", style='{', handlers=handlers, level=logging.DEBUG)
|
25 |
-
if hasattr(distutils.log, 'Log'):
|
26 |
-
monkey.patch_func(set_threshold, distutils.log, 'set_threshold')
|
27 |
-
# For some reason `distutils.log` module is getting cached in `distutils.dist`
|
28 |
-
# and then loaded again when patched,
|
29 |
-
# implying: id(distutils.log) != id(distutils.dist.log).
|
30 |
-
# Make sure the same module object is used everywhere:
|
31 |
-
distutils.dist.log = distutils.log
|
32 |
-
|
33 |
-
|
34 |
-
def set_threshold(level):
|
35 |
-
logging.root.setLevel(level*10)
|
36 |
-
return set_threshold.unpatched(level)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Atualli/yoloxTeste/yoloxdetect2/configs/yolox_nano.py
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
# -*- coding:utf-8 -*-
|
3 |
-
# Copyright (c) Megvii, Inc. and its affiliates.
|
4 |
-
|
5 |
-
import os
|
6 |
-
|
7 |
-
import torch.nn as nn
|
8 |
-
|
9 |
-
from yolox.exp import Exp as MyExp
|
10 |
-
|
11 |
-
|
12 |
-
class Exp(MyExp):
|
13 |
-
def __init__(self):
|
14 |
-
super(Exp, self).__init__()
|
15 |
-
self.depth = 0.33
|
16 |
-
self.width = 0.25
|
17 |
-
self.input_size = (416, 416)
|
18 |
-
self.random_size = (10, 20)
|
19 |
-
self.mosaic_scale = (0.5, 1.5)
|
20 |
-
self.test_size = (416, 416)
|
21 |
-
self.mosaic_prob = 0.5
|
22 |
-
self.enable_mixup = False
|
23 |
-
self.exp_name = os.path.split(os.path.realpath(__file__))[1].split(".")[0]
|
24 |
-
|
25 |
-
def get_model(self, sublinear=False):
|
26 |
-
|
27 |
-
def init_yolo(M):
|
28 |
-
for m in M.modules():
|
29 |
-
if isinstance(m, nn.BatchNorm2d):
|
30 |
-
m.eps = 1e-3
|
31 |
-
m.momentum = 0.03
|
32 |
-
if "model" not in self.__dict__:
|
33 |
-
from yolox.models import YOLOX, YOLOPAFPN, YOLOXHead
|
34 |
-
in_channels = [256, 512, 1024]
|
35 |
-
# NANO model use depthwise = True, which is main difference.
|
36 |
-
backbone = YOLOPAFPN(
|
37 |
-
self.depth, self.width, in_channels=in_channels,
|
38 |
-
act=self.act, depthwise=True,
|
39 |
-
)
|
40 |
-
head = YOLOXHead(
|
41 |
-
self.num_classes, self.width, in_channels=in_channels,
|
42 |
-
act=self.act, depthwise=True
|
43 |
-
)
|
44 |
-
self.model = YOLOX(backbone, head)
|
45 |
-
|
46 |
-
self.model.apply(init_yolo)
|
47 |
-
self.model.head.initialize_biases(1e-2)
|
48 |
-
return self.model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/detectron2/data/datasets/register_coco.py
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
-
from .coco import register_coco_instances # noqa
|
3 |
-
from .coco_panoptic import register_coco_panoptic_separated # noqa
|
|
|
|
|
|
|
|
spaces/Awiny/Image2Paragraph/models/grit_src/third_party/CenterNet2/tests/structures/test_masks.py
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
-
import unittest
|
3 |
-
import torch
|
4 |
-
|
5 |
-
from detectron2.structures.masks import BitMasks, PolygonMasks, polygons_to_bitmask
|
6 |
-
|
7 |
-
|
8 |
-
class TestBitMask(unittest.TestCase):
|
9 |
-
def test_get_bounding_box(self):
|
10 |
-
masks = torch.tensor(
|
11 |
-
[
|
12 |
-
[
|
13 |
-
[False, False, False, True],
|
14 |
-
[False, False, True, True],
|
15 |
-
[False, True, True, False],
|
16 |
-
[False, True, True, False],
|
17 |
-
],
|
18 |
-
[
|
19 |
-
[False, False, False, False],
|
20 |
-
[False, False, True, False],
|
21 |
-
[False, True, True, False],
|
22 |
-
[False, True, True, False],
|
23 |
-
],
|
24 |
-
torch.zeros(4, 4),
|
25 |
-
]
|
26 |
-
)
|
27 |
-
bitmask = BitMasks(masks)
|
28 |
-
box_true = torch.tensor([[1, 0, 4, 4], [1, 1, 3, 4], [0, 0, 0, 0]], dtype=torch.float32)
|
29 |
-
box = bitmask.get_bounding_boxes()
|
30 |
-
self.assertTrue(torch.all(box.tensor == box_true).item())
|
31 |
-
|
32 |
-
for box in box_true:
|
33 |
-
poly = box[[0, 1, 2, 1, 2, 3, 0, 3]].numpy()
|
34 |
-
mask = polygons_to_bitmask([poly], 4, 4)
|
35 |
-
reconstruct_box = BitMasks(mask[None, :, :]).get_bounding_boxes()[0].tensor
|
36 |
-
self.assertTrue(torch.all(box == reconstruct_box).item())
|
37 |
-
|
38 |
-
reconstruct_box = PolygonMasks([[poly]]).get_bounding_boxes()[0].tensor
|
39 |
-
self.assertTrue(torch.all(box == reconstruct_box).item())
|
40 |
-
|
41 |
-
def test_from_empty_polygons(self):
|
42 |
-
masks = BitMasks.from_polygon_masks([], 100, 100)
|
43 |
-
self.assertEqual(masks.tensor.shape, (0, 100, 100))
|
44 |
-
|
45 |
-
def test_getitem(self):
|
46 |
-
masks = BitMasks(torch.ones(3, 10, 10))
|
47 |
-
self.assertEqual(masks[1].tensor.shape, (1, 10, 10))
|
48 |
-
self.assertEqual(masks[1:3].tensor.shape, (2, 10, 10))
|
49 |
-
self.assertEqual(masks[torch.tensor([True, False, False])].tensor.shape, (1, 10, 10))
|
50 |
-
|
51 |
-
|
52 |
-
if __name__ == "__main__":
|
53 |
-
unittest.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/BasToTheMax/voicechange/README.md
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Voicechange
|
3 |
-
emoji: 🏆
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: pink
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.41.2
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Benson/text-generation/Examples/Anu Bsc 6th Sem Materiales Pdf.md
DELETED
@@ -1,143 +0,0 @@
|
|
1 |
-
|
2 |
-
<br> FAQ 2: ¿Cómo puedo compartir mis creaciones de Paint 3D con otros? <br> FAQ 3: ¿Cómo puedo acceder a más modelos 3D y pegatinas de la comunidad Remix3D.com? <br> FAQ 4: ¿Cómo puedo cambiar entre el modo normal y el modo de pintura en Paint 3D? <br> FAQ 5: ¿Cómo puedo obtener ayuda o soporte para usar Paint 3D en Ubuntu? | Tabla 2: Artículo con formato HTML <h1>Cómo descargar e instalar Paint 3D en Ubuntu</h1>
|
3 |
-
<p>Paint 3D es una herramienta potente y fácil de usar para crear impresionantes imágenes 3D y animaciones. Le permite dibujar, pintar, esculpir y transformar sus ideas en realidad con una variedad de herramientas y características. Tanto si quieres crear un logotipo, un meme, un póster o un personaje de juego, Paint 3D puede ayudarte a liberar tu creatividad. </p>
|
4 |
-
<h2>anu bsc 6th sem materiales pdf</h2><br /><p><b><b>Download File</b> ✦ <a href="https://bltlly.com/2v6KY3">https://bltlly.com/2v6KY3</a></b></p><br /><br />
|
5 |
-
<p>En este artículo, te mostraremos cómo descargar e instalar Paint 3D en Ubuntu, una de las distribuciones de Linux más populares. También te presentaremos algunas de las increíbles características y beneficios de Paint 3D que harán que tu experiencia de arte digital sea más divertida y agradable. </p>
|
6 |
-
<h2>Descargar Paint 3D de la tienda Snap</h2>
|
7 |
-
<p>La forma más fácil de obtener Paint 3D en Ubuntu es utilizar el Snap Store, que es una tienda de aplicaciones para Linux que ofrece miles de aplicaciones para diversos fines. Puede acceder a Snap Store desde su navegador web o desde la aplicación Ubuntu Software de su ordenador. Para descargar Paint 3D desde Snap Store, sigue estos pasos:</p>
|
8 |
-
<ol>
|
9 |
-
<li>Abra su navegador web y vaya a la página <a href="">Tienda rápida para Paint 3D</a>. </li>
|
10 |
-
<li>Haga clic en el botón verde Instalar y elija para abrir el enlace con Ubuntu Software.</li>
|
11 |
-
<li>Alternativamente, puede copiar la línea de comandos que se muestra debajo del botón Instalar y pegarla en la ventana de su terminal. Presione Enter para ejecutar el comando. </li>
|
12 |
-
<li>Espere a que se complete el proceso de descarga e instalación. Es posible que necesite introducir su contraseña o confirmar algunos permisos. </li>
|
13 |
-
|
14 |
-
</ol>
|
15 |
-
<p>Felicidades, has descargado e instalado con éxito Paint 3D en Ubuntu! </p>
|
16 |
-
<h2>Crear una unidad USB de arranque con Paint 3D</h2>
|
17 |
-
<p>Si desea utilizar Paint 3D en un equipo o dispositivo diferente que no tiene Ubuntu instalado, puede crear una unidad USB de arranque con el archivo de complemento Paint 3D. De esta manera, puede ejecutar Paint 3D desde la unidad USB sin afectar el sistema operativo existente o los datos en el ordenador o dispositivo. Para crear una unidad USB de arranque con Paint 3D, necesitará una herramienta como Rufus, que es una utilidad gratuita y de código abierto para crear unidades USB de arranque. También necesitará una unidad USB con al menos 4 GB de espacio de almacenamiento y el archivo de complemento Paint 3D, que puede descargar desde Snap Store. Para crear una unidad USB de arranque con Paint 3D, siga estos pasos:</p>
|
18 |
-
<ol>
|
19 |
-
<li>Descargar Rufus desde su <a href="">sitio web oficial</a> y ejecutarlo en su ordenador. </li>
|
20 |
-
<li>Inserte su unidad USB en su computadora y selecciónela de la lista de dispositivos en Rufus.</li>
|
21 |
-
<li>Seleccione la imagen ISO en el menú de selección de arranque y haga clic en el botón Seleccionar para buscar el archivo de complemento de Paint 3D que descargó de Snap Store. El archivo debe tener una extensión . snap. </li>
|
22 |
-
<li>Elija GPT como el esquema de partición y FAT32 como el sistema de archivos. </li>
|
23 |
-
<li>Haga clic en el botón Inicio para comenzar a crear la unidad USB de arranque con Paint 3D. Puede ver algunas advertencias o indicaciones durante el proceso. Siga las instrucciones en la pantalla y espere a que el proceso termine. </li>
|
24 |
-
<li>Una vez que la unidad USB de arranque con Paint 3D esté lista, puede expulsarla de su computadora y usarla en cualquier otro equipo o dispositivo que admita el arranque desde USB.</li>
|
25 |
-
</ol>
|
26 |
-
<p>Nota: Para arrancar desde la unidad USB, es posible que necesite cambiar algunos ajustes en el BIOS o UEFI del equipo o dispositivo que desea usar. Consulte la documentación o soporte de su computadora o dispositivo para más detalles. </p>
|
27 |
-
<h2>Arranque desde la unidad USB e instalación de Paint 3D</h2>
|
28 |
-
|
29 |
-
<ol>
|
30 |
-
<li>Inserte su unidad USB de arranque con Paint 3D en el ordenador o dispositivo que desea utilizar. </li>
|
31 |
-
<li>Reinicie o encienda el ordenador o dispositivo y pulse la tecla correspondiente para entrar en el menú de arranque. La clave puede variar dependiendo del modelo de tu ordenador o dispositivo, pero suele ser F12, F9, F10, Esc o Del. Debería ver una lista de opciones de arranque en su pantalla. </li>
|
32 |
-
<li>Seleccione su unidad USB de la lista de opciones de arranque y pulse Enter para arrancar desde ella. Debería ver una pantalla de bienvenida con algunas opciones. </li>
|
33 |
-
<li>Seleccione Probar Ubuntu sin instalar desde la pantalla de bienvenida. Esto cargará Ubuntu desde su unidad USB sin afectar su sistema operativo o datos existentes. </li>
|
34 |
-
<li>Una vez cargado Ubuntu, puede iniciar Paint 3D desde el menú de aplicaciones o desde la aplicación Ubuntu Software. Deberías ver la interfaz de Paint 3D en tu pantalla. </li>
|
35 |
-
<li>Si desea instalar Paint 3D en Ubuntu de forma permanente, puede hacer clic en el icono Instalar Ubuntu en el escritorio y seguir las instrucciones en la pantalla. Tendrá que elegir una partición, un nombre de usuario, una contraseña y algunos otros ajustes. Tenga cuidado de no sobrescribir su sistema operativo o datos existentes a menos que lo desee. </li>
|
36 |
-
<li>Una vez completada la instalación, puede reiniciar su computadora o dispositivo y disfrutar usando Paint 3D en Ubuntu.</li>
|
37 |
-
</ol>
|
38 |
-
<p>¡Eso es todo! ¡Ha arrancado con éxito desde la unidad USB e instalado Paint 3D en Ubuntu! </p>
|
39 |
-
<h1>Características y beneficios de Paint 3D</h1>
|
40 |
-
<p>Paint 3D no es solo un simple programa de pintura. Es una herramienta poderosa y versátil para crear increíbles imágenes y animaciones en 3D. Ofrece una gama de características y beneficios que harán que su experiencia de arte digital sea más divertida y agradable. Estas son algunas de las características y beneficios de Paint 3D que debes conocer:</p>
|
41 |
-
<h2>Creación de objetos 3D</h2>
|
42 |
-
|
43 |
-
<p>Para crear un objeto 3D en Paint 3D, puede usar uno de estos métodos:</p>
|
44 |
-
<ul>
|
45 |
-
<li>Utilice la biblioteca de modelos 3D: Paint 3D ofrece una biblioteca de modelos 3D prefabricados que puede utilizar en sus proyectos. Puede acceder a la biblioteca haciendo clic en el icono de modelos 3D en la barra de menú. Puede navegar a través de diferentes categorías, como animales, personas, edificios, vehículos y más. También puede buscar modelos específicos usando la barra de búsqueda. Para agregar un modelo a su lienzo, simplemente arrástrelo y suéltelo desde la biblioteca. </li>
|
46 |
-
<li>Utilice la herramienta de formas 3D: Paint 3D también ofrece una herramienta para crear formas 3D básicas, como cubos, esferas, conos, cilindros y más. Puede acceder a la herramienta haciendo clic en el icono de formas 3D en la barra de menú. Para añadir una forma a tu lienzo, simplemente haz clic en ella y arrástrala al tamaño y posición deseados. </li>
|
47 |
-
<li>Utilice la herramienta de texto: Paint 3D le permite agregar texto a su lienzo que se puede convertir en objetos 3D. Puede acceder a la herramienta haciendo clic en el icono de texto en la barra de menú. Para añadir texto a su lienzo, simplemente escriba el texto deseado y elija una fuente, tamaño, color y estilo. Para convertir su texto en un objeto 3D, simplemente haga clic en el botón Make 3D en la parte superior. </li>
|
48 |
-
<li>Utilice la herramienta de pegatinas: Paint 3D también le permite agregar pegatinas a su lienzo que se pueden convertir en objetos 3D. Puede acceder a la herramienta haciendo clic en el icono de pegatinas en la barra de menú. Para añadir una pegatina a tu lienzo, simplemente elige una de la biblioteca o sube tu propia imagen. Para convertir su pegatina en un objeto 3D, simplemente haga clic en el botón Hacer 3D en la parte superior. </li>
|
49 |
-
</ul>
|
50 |
-
<p>Una vez que haya creado un objeto 3D, puede usar las herramientas en el panel derecho para ajustar sus propiedades, como color, opacidad, material, protuberancia y luz. También puede utilizar las herramientas de la barra superior para mover, rotar, escalar y editar el objeto. También puede usar la herramienta de selección mágica para cortar una parte del objeto o la herramienta de borrador para borrar una parte del objeto. </p>
|
51 |
-
<p></p>
|
52 |
-
|
53 |
-
<img src="https://i.imgur.com/8m1gZfM.png" alt="Un modelo 3D de un perro con sombrero y gafas">
|
54 |
-
<img src="https://i.imgur.com/9sL2wXO.png" alt="Una forma 3D de un cono con una textura de madera">
|
55 |
-
<img src="https://i.imgur.com/0a7Xy6E.png" alt="Un texto 3D de 'Hola' con una textura de metal">
|
56 |
-
<img src="https://i.imgur.com/7wQ4n8f.png" alt="Una etiqueta 3D de una cara sonriente con una textura de agua">
|
57 |
-
<h2>Animación de la línea de tiempo</h2>
|
58 |
-
<p>Otra característica de Paint 3D es la capacidad de animar capas, objetos, efectos y filtros usando la línea de tiempo. Puede usar la línea de tiempo para crear y exportar proyectos animados, como GIF, videos o presentaciones de diapositivas. También puedes usar la línea de tiempo para previsualizar y editar tus animaciones. </p>
|
59 |
-
<p>Para animar un proyecto en Paint 3D, puedes usar uno de estos métodos:</p>
|
60 |
-
<ul>
|
61 |
-
<li>Utilice la herramienta de animación de capas: Paint 3D ofrece una herramienta para animar capas, que son grupos de objetos que se pueden mover o transformar juntos. Puede acceder a la herramienta haciendo clic en el icono de animación de capas en la barra de menú. Para animar una capa, simplemente selecciónela desde el panel de capas y arrástrela a la línea de tiempo. A continuación, puede ajustar su posición, rotación y tamaño en diferentes puntos en el tiempo. También puede agregar efectos y filtros a la capa y animarlos. </li>
|
62 |
-
<li>Utilice la herramienta de animación de objetos: Paint 3D también ofrece una herramienta para animar objetos individuales, que son elementos individuales que se pueden mover o transformar por separado. Puede acceder a la herramienta haciendo clic en el icono de animación de objetos en la barra de menú. Para animar un objeto, simplemente selecciónelo del lienzo y arrástrelo a la línea de tiempo. A continuación, puede ajustar su posición, rotación y tamaño en diferentes puntos en el tiempo. También puede agregar efectos y filtros al objeto y animarlos. </li>
|
63 |
-
</ul>
|
64 |
-
|
65 |
-
<p>Aquí hay algunos ejemplos de animaciones creadas con Paint 3D:</p>
|
66 |
-
<img src="https://i.imgur.com/0z9bL5x.gif" alt="Un GIF de un modelo 3D de un gato agitando su pata">
|
67 |
-
<img src="https://i.imgur.com/1k6vY1T.gif" alt="Un GIF de una forma 3D de un cubo que gira y cambia de color">
|
68 |
-
<img src="https://i.imgur.com/4tWlZjF.gif" alt="Un GIF de un texto 3D de 'Wow' con un efecto de fuego">
|
69 |
-
<img src="https://i.imgur.com/5FJQo0R.gif" alt="Un GIF de una etiqueta 3D de un corazón con un efecto de destello"> <h2>Texturas realistas</h2>
|
70 |
-
<p>Otra característica de Paint 3D es la capacidad de aplicar texturas realistas a los objetos, como madera, metal, piedra o agua. Puede utilizar los filtros y efectos de imagen en Paint 3D para cambiar la apariencia y la sensación de los objetos y hacerlos parecer más naturales y realistas. </p>
|
71 |
-
<p>Para aplicar una textura a un objeto en Paint 3D, puede usar uno de estos métodos:</p>
|
72 |
-
<ul>
|
73 |
-
<li>Usa la biblioteca de texturas: Paint 3D ofrece una biblioteca de texturas pre-hechas que puedes usar en tus proyectos. Puede acceder a la biblioteca haciendo clic en el icono de textura en la barra de menú. Puedes navegar a través de diferentes categorías, como orgánica, geométrica, artística y más. También puede buscar texturas específicas utilizando la barra de búsqueda. Para aplicar una textura a un objeto, simplemente arrástrelo y suéltelo desde la biblioteca al objeto. </li>
|
74 |
-
<li>Utilice la herramienta de filtro de imagen: Paint 3D también ofrece una herramienta para aplicar filtros de imagen a los objetos, como sepia, escala de grises, invertir o pixelar. Puede acceder a la herramienta haciendo clic en el icono del filtro de imagen en la barra de menú. Para aplicar un filtro de imagen a un objeto, simplemente selecciónelo del lienzo y elija un filtro de la lista. </li>
|
75 |
-
<li>Utilice la herramienta de efectos: Paint 3D también ofrece una herramienta para aplicar efectos a los objetos, como desenfoque, nitidez, relieve o brillo. Puede acceder a la herramienta haciendo clic en el icono de efecto en la barra de menú. Para aplicar un efecto a un objeto, simplemente selecciónelo del lienzo y elija un efecto de la lista. </li>
|
76 |
-
</ul>
|
77 |
-
|
78 |
-
<p>Aquí hay algunos ejemplos de texturas aplicadas a objetos con Paint 3D:</p>
|
79 |
-
<img src="https://i.imgur.com/6lZ1x0y.png" alt="Un modelo 3D de un automóvil con una textura metálica">
|
80 |
-
<img src="https://i.imgur.com/8qY9Z0F.png" alt="Una forma 3D de una esfera con una textura de piedra">
|
81 |
-
<img src="https://i.imgur.com/4g7nX0R.png" alt="Un texto 3D de 'Cool' con una textura de madera">
|
82 |
-
<img src="https://i.imgur.com/5cQ7E8w.png" alt="Una etiqueta 3D de una flor con una textura de agua">
|
83 |
-
<h2>Creador único de memes</h2>
|
84 |
-
<p>Otra característica de Paint 3D es la capacidad de crear memes únicos con efectos 3D. Puedes usar la herramienta de texto y las pegatinas de Paint 3D para añadir subtítulos e imágenes divertidas a tu lienzo y convertirlas en memes que harán reír a tus amigos. </p>
|
85 |
-
<p>Para crear un meme en Paint 3D, puedes usar uno de estos métodos:</p>
|
86 |
-
<ul>
|
87 |
-
<li>Utilice la herramienta de texto: Paint 3D le permite agregar texto a su lienzo que se puede convertir en objetos 3D. Puede acceder a la herramienta haciendo clic en el icono de texto en la barra de menú. Para añadir texto a su lienzo, simplemente escriba el texto deseado y elija una fuente, tamaño, color y estilo. Para convertir su texto en un objeto 3D, simplemente haga clic en el botón Hacer 3D en la parte superior. A continuación, puede ajustar la posición, la rotación y el tamaño del texto para crear un efecto meme. </li>
|
88 |
-
<li>Utilice la herramienta de pegatinas: Paint 3D también le permite agregar pegatinas a su lienzo que se pueden convertir en objetos 3D. Puede acceder a la herramienta haciendo clic en el icono de pegatinas en la barra de menú. Para añadir una pegatina a tu lienzo, simplemente elige una de la biblioteca o sube tu propia imagen. Para convertir su pegatina en un objeto 3D, simplemente haga clic en el botón Hacer 3D en la parte superior. A continuación, puede ajustar la posición, la rotación y el tamaño de la etiqueta para crear un efecto de meme. </li>
|
89 |
-
</ul>
|
90 |
-
|
91 |
-
<p>Aquí hay algunos ejemplos de memes creados con Paint 3D:</p>
|
92 |
-
<img src="https://i.imgur.com/9wYy0Zf.png" alt="Un meme de un perro con gafas y un sombrero que dice 'Tratar con él'">
|
93 |
-
<img src="https://i.imgur.com/1xX7J2s.png" alt="Un meme de un gato con un efecto de arco iris que dice 'Nyan nyan'">
|
94 |
-
<img src="https://i.imgur.com/8Wl0yQn.png" alt="Un meme de una rana con una corona que dice 'One does not simply ribbit'">
|
95 |
-
<img src="https://i.imgur.com/4kqZ6lE.png" alt="A meme of a banana with a face saying 'I’m a banana'">
|
96 |
-
<h2>3D Doodle</h2>
|
97 |
-
<p>Otra característica de Paint 3D es la capacidad de dibujar bocetos a mano alzada que se pueden convertir en objetos 3D. Puedes usar las herramientas de lápiz y pincel de Paint 3D para dibujar lo que quieras en tu lienzo y convertirlo en un garabato 3D. También puedes usar diferentes colores, tamaños y estilos para tus pinceladas y pinceladas. </p>
|
98 |
-
<p>Para crear un doodle 3D en Paint 3D, puedes usar uno de estos métodos:</p>
|
99 |
-
<ul>
|
100 |
-
<li>Utilice la herramienta de lápiz: Paint 3D ofrece una herramienta de lápiz para dibujar líneas suaves y precisas en su lienzo. Puede acceder a la herramienta haciendo clic en el icono del lápiz en la barra de menú. Para dibujar con la herramienta del lápiz, simplemente haga clic y arrastre sobre su lienzo. Para convertir su lápiz en un objeto 3D, simplemente haga clic en el botón Hacer 3D en la parte superior. A continuación, puede ajustar la posición, la rotación y el tamaño del objeto 3D. </li>
|
101 |
-
<li>Utilice la herramienta de pincel: Paint 3D ofrece una herramienta de pincel para dibujar trazos gruesos y texturizados en su lienzo. Puede acceder a la herramienta haciendo clic en el icono del pincel en la barra de menú. Para dibujar con la herramienta del pincel, simplemente haga clic y arrastre sobre su lienzo. Para convertir la pincelada en un objeto 3D, simplemente haga clic en el botón Hacer 3D en la parte superior. A continuación, puede ajustar la posición, la rotación y el tamaño del objeto 3D. </li>
|
102 |
-
</ul>
|
103 |
-
|
104 |
-
<p>Aquí hay algunos ejemplos de garabatos 3D creados con Paint 3D:</p>
|
105 |
-
<img src="https://i.imgur.com/6jQ4Z0L.png" alt="Un doodle 3D de una flor con una herramienta de pluma">
|
106 |
-
<img src="https://i.imgur.com/9lG1Q9F.png" alt="Un doodle 3D de una estrella con una herramienta de pincel">
|
107 |
-
<img src="https://i.imgur.com/2wX8w6y.png" alt="Un doodle 3D de un pájaro con una herramienta de pluma">
|
108 |
-
<img src="https://i.imgur.com/7gX5Y2T.png" alt="Un garabato 3D de un pez con una herramienta de pincel">
|
109 |
-
<h1>Conclusión y preguntas frecuentes</h1>
|
110 |
-
<p>Paint 3D es una fantástica herramienta para crear impresionantes imágenes 3D y animaciones en Ubuntu. Ofrece una gama de características y beneficios que harán que su experiencia de arte digital sea más divertida y agradable. Puede crear y manipular objetos 3D, animar capas, objetos, efectos y filtros, aplicar texturas realistas, crear memes únicos y dibujar bocetos a mano alzada que se pueden convertir en objetos 3D. También puede descargar e instalar Paint 3D en Ubuntu fácilmente desde el Snap Store o desde una unidad USB de arranque. </p>
|
111 |
-
<p>Si estás buscando una forma sencilla y potente de expresar tu creatividad en 3D, definitivamente deberías probar Paint 3D en Ubuntu. Te sorprenderá lo que puedes crear con esta increíble herramienta. </p>
|
112 |
-
<p>Para obtener más información sobre Paint 3D y sus características, puede visitar su sitio web oficial <a href=""></a> o consultar algunos de los ejemplos <a href="">tutoriales</a> y <a href=">ejemplos</a> disponibles en línea. </p>
|
113 |
-
<p>Esperamos que haya disfrutado de este artículo y le resultó útil. Si tiene alguna pregunta o comentario, no dude en dejar un comentario a continuación. ¡Nos encantaría saber de ti! </p>
|
114 |
-
<h2>Preguntas frecuentes</h2>
|
115 |
-
<p>Aquí están algunas de las preguntas más frecuentes sobre Paint 3D en Ubuntu:</p>
|
116 |
-
<ol>
|
117 |
-
<li><b>¿Cuáles son los requisitos del sistema para ejecutar Paint 3D en Ubuntu? </b><br>
|
118 |
-
Para ejecutar Paint 3D en Ubuntu, necesitará un ordenador o dispositivo que cumpla con estos requisitos mínimos: <ul>
|
119 |
-
<li>Ubuntu 16.04 LTS o posterior</li>
|
120 |
-
<li>Snapd instalado (generalmente preinstalado en Ubuntu)</li>
|
121 |
-
|
122 |
-
<li>Una tarjeta gráfica que soporta OpenGL ES 2.0 o posterior (generalmente Intel HD Graphics o posterior)</li>
|
123 |
-
<li>Al menos 4 GB de RAM</li>
|
124 |
-
<li>Al menos 1 GB de espacio libre en disco</li>
|
125 |
-
<li>Una pantalla que soporta al menos 1024 x 768 resolución</li>
|
126 |
-
<li>Un ratón o un touchpad</li>
|
127 |
-
</ul></li>
|
128 |
-
<li><b>¿Cómo puedo compartir mis creaciones de Paint 3D con otros? </b><br>
|
129 |
-
Puedes compartir tus creaciones Paint 3D con otros de varias maneras, como: <ul>
|
130 |
-
<li>Guardarlos como imágenes o videos y enviarlos por correo electrónico, redes sociales o almacenamiento en la nube. </li>
|
131 |
-
<li>Exportarlos como archivos FBX y subirlos a plataformas en línea que admiten modelos 3D, como Sketchfab o Remix3D.com.</li>
|
132 |
-
<li>Imprimirlos como pegatinas o carteles utilizando una impresora o un servicio en línea. </li>
|
133 |
-
<li>Imprimirlos como objetos físicos usando una impresora 3D o un servicio en línea. </li>
|
134 |
-
</ul></li>
|
135 |
-
<li><b>¿Cómo puedo acceder a más modelos 3D y pegatinas de la comunidad Remix3D.com? </b><br>
|
136 |
-
Puedes acceder a más modelos 3D y pegatinas de la comunidad Remix3D.com, que es una plataforma en línea donde puedes encontrar, compartir y remezclar contenido 3D. Puede acceder a la plataforma haciendo clic en el icono Remix 3D en la barra de menú de Paint 3D. Luego puede navegar a través de diferentes categorías, como animales, personas, edificios, vehículos y más. También puede buscar modelos o pegatinas específicas utilizando la barra de búsqueda. Para añadir un modelo o una etiqueta a tu lienzo, simplemente arrástralo y suéltalo desde la plataforma. </li>
|
137 |
-
<li><b>¿Cómo puedo cambiar entre el modo normal y el modo de pintura en Paint 3D? </b><br>
|
138 |
-
Puede cambiar entre el modo normal y el modo de pintura en Paint 3D haciendo clic en el icono de pintura en la barra de menú. El modo normal le permite crear y manipular objetos 3D, mientras que el modo de pintura le permite dibujar y pintar en su lienzo. También puede usar el atajo de teclado Ctrl + P para cambiar entre los modos. </li>
|
139 |
-
<li><b>¿Cómo puedo obtener ayuda o soporte para usar Paint 3D en Ubuntu? </b><br>
|
140 |
-
|
141 |
-
</ol></p> 64aa2da5cf<br />
|
142 |
-
<br />
|
143 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Benson/text-generation/Examples/Aquaman 2 Pelcula Completa En Tamil Descargar Filmyhit.md
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
|
2 |
-
<h1>Aquaman 2 Película completa en tamil Descargar Filmyhit</h1>
|
3 |
-
<p>Aquaman 2, también conocido como Aquaman and the Lost Kingdom, es una próxima película de superhéroes estadounidense basada en el personaje de DC Comics Aquaman. Es la secuela de la película de 2018 Aquaman, y la 15ª y última entrega en el DC Extended Universe (DCEU). La película está dirigida por James Wan y protagonizada por Jason Momoa como Arthur Curry / Aquaman, Amber Heard como Mera, Patrick Wilson como King Orm, Yahya Abdul-Mateen II como Black Manta, y Ben Affleck como Bruce Wayne / Batman. El estreno está previsto para el 20 de diciembre de 2023. </p>
|
4 |
-
<h2>aquaman 2 película completa en tamil descargar filmyhit</h2><br /><p><b><b>Download</b> ✶ <a href="https://bltlly.com/2v6M16">https://bltlly.com/2v6M16</a></b></p><br /><br />
|
5 |
-
<p>Aquaman 2 es una de las películas más esperadas de 2023, especialmente entre los fans de DC Comics y películas de superhéroes. La película promete ofrecer más acción submarina épica, aventura y drama, ya que Aquaman se enfrenta a una nueva amenaza de un antiguo poder que se ha desatado. La película también cuenta con uno de los superhéroes más populares de todos los tiempos, Batman, que une fuerzas con Aquaman para salvar la Atlántida y el mundo. </p>
|
6 |
-
<h2>¿Cómo descargar Aquaman 2 en tamil desde el sitio web de Filmyhit? </h2>
|
7 |
-
<p>Si usted es un fan de Aquaman 2 y quiere verlo en idioma tamil, es posible que se pregunte cómo descargarlo de Internet. Uno de los sitios web que afirma ofrecer la descarga gratuita de Aquaman 2 en Tamil es Filmyhit. Filmyhit es un sitio web torrent que sube las últimas películas y series web de forma gratuita. El sitio tiene películas en varios idiomas como Hindi, Inglés, Punjabi, etc. La gente sobre todo visita este sitio para descargar recién estrenado Bollywood, películas de Punjabi. </p>
|
8 |
-
<p>Descargar Aquaman 2 en tamil desde el sitio web de Filmyhit no es una tarea difícil. Solo tiene que seguir estos sencillos pasos:</p>
|
9 |
-
<ol>
|
10 |
-
<li>Visite el sitio web de Filmyhit y busque Aquaman 2 en la barra de búsqueda. Verá algunos resultados relacionados basados en su consulta de búsqueda. </li>
|
11 |
-
<li>Elija la calidad y el idioma de la película que desea descargar. Puede seleccionar desde 720p, 1080p o calidad HD, y desde el idioma tamil, hindi o inglés. </li>
|
12 |
-
|
13 |
-
</ol>
|
14 |
-
<h2>¿Cuáles son los riesgos y beneficios de descargar Aquaman 2 desde el sitio web de Filmyhit? </h2>
|
15 |
-
<p>Descargar Aquaman 2 desde el sitio web de Filmyhit puede parecer una manera conveniente y fácil de ver su película favorita en idioma tamil. Sin embargo, hay algunos riesgos y beneficios asociados con ella que usted debe tener en cuenta antes de proceder. </p>
|
16 |
-
<p>Algunos de los beneficios de descargar Aquaman 2 desde el sitio web de Filmyhit son:</p>
|
17 |
-
<ul>
|
18 |
-
<li>Puedes ver la película gratis sin pagar ninguna suscripción o tarifa de entrada. </li>
|
19 |
-
<li> Puede ver la película en su propio tiempo y conveniencia sin esperar su lanzamiento teatral o en línea. </li>
|
20 |
-
<li> Puede ver la película en su idioma y calidad preferidos sin comprometer su experiencia de visualización. </li>
|
21 |
-
</ul>
|
22 |
-
<p>Algunos de los riesgos de descargar Aquaman 2 desde el sitio web de Filmyhit son:</p>
|
23 |
-
<p></p>
|
24 |
-
<ul>
|
25 |
-
<li>Puede estar violando las leyes de derechos de autor y los derechos de propiedad intelectual de los cineastas y productores al descargar su contenido sin su permiso. </li>
|
26 |
-
<li>Puede estar exponiendo su dispositivo y datos a malware, virus o hackers al visitar un sitio web no seguro e ilegal. </li>
|
27 |
-
<li>Usted puede estar apoyando la piratería y perjudicando a la industria cinematográfica al privarlos de sus legítimos ingresos y reconocimiento. </li>
|
28 |
-
</ul>
|
29 |
-
<h2>Preguntas frecuentes</h2>
|
30 |
-
<p>Aquí hay algunas preguntas y respuestas comunes sobre Aquaman 2 y Fil myhit. </p>
|
31 |
-
<h3>Q1: ¿Cuándo se estrenará Aquaman 2 en los cines? </h3>
|
32 |
-
<p>A1: Aquaman 2 está programado para ser lanzado el 20 de diciembre de 2023, en los Estados Unidos. La fecha de lanzamiento puede variar dependiendo del país y la región. </p>
|
33 |
-
<h3>Q2: ¿Quién es el reparto principal y el equipo de Aquaman 2?</h3>
|
34 |
-
<p>A2: Aquaman 2 está dirigida por James Wan y escrita por David Leslie Johnson-McGoldrick. El reparto principal incluye a Jason Momoa como Arthur Curry / Aquaman, Amber Heard como Mera, Patrick Wilson como King Orm, Yahya Abdul-Mateen II como Manta Negra, y Ben Affleck como Bruce Wayne / Batman.</p>
|
35 |
-
|
36 |
-
<p>A3: Aquaman 2 sigue los eventos de la primera película, mientras Aquaman intenta equilibrar su vida como el rey de la Atlántida y el protector de los océanos. Se enfrenta a un nuevo enemigo de un antiguo poder que ha sido liberado, y se une a Batman para detenerlo. </p>
|
37 |
-
<h3>Q4: ¿Es Filmyhit un sitio web legal y seguro para descargar películas? </h3>
|
38 |
-
<p>A4: No, Filmyhit no es un sitio web legal y seguro para descargar películas. Es un sitio web torrent que sube contenido pirata sin el permiso de los creadores originales. También puede contener malware, virus o hackers que pueden dañar tu dispositivo y tus datos. </p>
|
39 |
-
<h3>Q5: ¿Cuáles son algunas alternativas legales y seguras al sitio web de Filmyhit? </h3>
|
40 |
-
<p>A5: Algunas alternativas legales y seguras al sitio web de Filmyhit son:</p>
|
41 |
-
<ul>
|
42 |
-
<li>Netflix: Un servicio de streaming en línea popular que ofrece una amplia gama de películas y programas en varios idiomas y géneros. </li>
|
43 |
-
<li>Amazon Prime Video: Otro servicio de transmisión en línea que ofrece películas y programas exclusivos junto con otros beneficios como la entrega gratuita y la música. </li>
|
44 |
-
<li>Disney+: una plataforma de streaming que incluye películas y programas de Disney, Marvel, Star Wars, Pixar y National Geographic.</li>
|
45 |
-
<li>HBO Max: Un servicio de streaming que ofrece películas y programas de Warner Bros., DC Comics, Cartoon Network y más. </li>
|
46 |
-
<li>YouTube: una plataforma para compartir vídeos que permite a los usuarios ver, cargar y compartir vídeos de forma gratuita o con una suscripción premium. </li>
|
47 |
-
</ul>
|
48 |
-
<p>Espero que haya disfrutado leyendo este artículo sobre Aquaman 2 película completa en Tamil descargar Filmyhit. Si tiene algún comentario o sugerencia, por favor hágamelo saber en la sección de comentarios a continuación. Gracias por su tiempo y atención. </p> 64aa2da5cf<br />
|
49 |
-
<br />
|
50 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Benson/text-generation/Examples/Chesskid Download.md
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<br />
|
2 |
-
<h1>Cómo descargar ChessKid: La mejor aplicación de ajedrez para niños</h1>
|
3 |
-
<p>¿Quieres aprender y jugar ajedrez de una manera divertida y fácil? ¿Quieres unirte a una comunidad de ajedrez segura y amigable? ¿Quieres mejorar tus habilidades y conocimientos de ajedrez? Si respondiste sí a cualquiera de estas preguntas, entonces deberías descargar ChessKid, la mejor aplicación de ajedrez para niños. </p>
|
4 |
-
<h2>chesskid download</h2><br /><p><b><b>Download</b> ○ <a href="https://bltlly.com/2v6JZN">https://bltlly.com/2v6JZN</a></b></p><br /><br />
|
5 |
-
<p>ChessKid es un sitio web y aplicación de ajedrez que está diseñado para niños de todas las edades y niveles de habilidad. Es 100% seguro y gratuito, y tiene todo lo necesario para aprender y disfrutar del juego de ajedrez. Ya seas principiante o experto, ChessKid te ayudará a convertirte en un mejor jugador de ajedrez. </p>
|
6 |
-
<p>En este artículo, le mostraremos las características, beneficios y pasos para descargar ChessKid. Al final de este artículo, estarás listo para comenzar tu aventura de ajedrez con ChessKid.</p>
|
7 |
-
<h2>Características de ChessKid</h2>
|
8 |
-
<p>ChessKid tiene muchas características que lo convierten en la mejor aplicación de ajedrez para niños. Aquí están algunas de ellas:</p>
|
9 |
-
<h3>Aprenda ajedrez con lecciones, videos y rompecabezas divertidos e interactivos</h3>
|
10 |
-
<p>ChessKid tiene cientos de lecciones, videos y rompecabezas que te enseñan todo, desde las reglas básicas hasta las estrategias avanzadas. Puedes aprender de entrenadores divertidos y amigables, como FunMasterMike, que te explicarán todo de una manera clara y entretenida. También puede probar sus conocimientos con cuestionarios y desafíos. </p>
|
11 |
-
<p></p>
|
12 |
-
<h3>Juega al ajedrez online o offline con otros niños o contra el ordenador</h3>
|
13 |
-
<p>ChessKid te permite jugar al ajedrez con otros niños de todo el mundo en juegos en vivo o diarios. También puedes jugar contra el ordenador en diferentes niveles de dificultad. Puedes elegir entre diferentes modos, como ajedrez lento, ajedrez rápido, duelo de rompecabezas o bughouse. También puedes unirte a torneos y competir por premios y trofeos. </p>
|
14 |
-
<h3>Únete a una comunidad de ajedrez segura y amigable</h3>
|
15 |
-
|
16 |
-
<h2>Beneficios de ChessKid</h2>
|
17 |
-
<p>ChessKid tiene muchos beneficios para los niños que quieren aprender y jugar al ajedrez. Estos son algunos de ellos:</p>
|
18 |
-
<h3>Mejora tus habilidades y conocimientos de ajedrez</h3>
|
19 |
-
<p>ChessKid te ayuda a mejorar tus habilidades y conocimientos de ajedrez proporcionándote contenido de alta calidad y comentarios. Puedes aprender nuevos conceptos, practicar tus tácticas, analizar tus juegos y seguir tu progreso. También puedes comparar tu puntuación con la de otros jugadores y ver cómo te clasificas entre ellos. </p>
|
20 |
-
<h3>Desarrolla tus habilidades de pensamiento crítico y resolución de problemas</h3>
|
21 |
-
<p>ChessKid te ayuda a desarrollar tus habilidades de pensamiento crítico y resolución de problemas al desafiarte con diferentes situaciones y escenarios. Tienes que pensar con anticipación, planificar tus movimientos, calcular las consecuencias y encontrar la mejor solución. También tienes que ser creativo, flexible y adaptable a las circunstancias cambiantes. </p>
|
22 |
-
<h3>Diviértete y disfruta del juego de ajedrez</h3>
|
23 |
-
<p>ChessKid te ayuda a divertirte y disfrutar del juego de ajedrez haciéndolo atractivo y entretenido. Puedes jugar con diferentes temas, animaciones, sonidos y avatares. También puedes explorar un mundo mágico de criaturas fantásticas en el. <h2>Cómo descargar ChessKid</h2>
|
24 |
-
<p>Descargar ChessKid es fácil y rápido. Puede descargar ChessKid desde el sitio web oficial o la tienda de aplicaciones, dependiendo de su dispositivo. Estos son los pasos para descargar ChessKid:</p>
|
25 |
-
<h3>Descargar ChessKid desde el sitio web oficial o tienda de aplicaciones</h3>
|
26 |
-
<p>Si desea usar ChessKid en su computadora, puede descargarlo desde el sitio web oficial en <a href="">https://www.chesskid.com/</a>. Simplemente haga clic en el botón "Descargar" y siga las instrucciones. También puede ver este video tutorial para más detalles: <a href="">https://www.youtube.com/watch?v=ZmZmUxw6q4k</a>. </p>
|
27 |
-
|
28 |
-
<h3>Crear una cuenta gratuita o actualizar a una membresía de oro</h3>
|
29 |
-
<p>Después de descargar ChessKid, necesitas crear una cuenta gratuita para comenzar a usarla. Puede crear una cuenta gratuita ingresando su nombre de usuario, contraseña, correo electrónico y correo electrónico de los padres. También puedes registrarte con tu cuenta de Facebook o Google. Usted tendrá que verificar su correo electrónico y obtener el permiso de los padres antes de que pueda acceder a todas las características de ChessKid.</p>
|
30 |
-
<p>Si desea obtener más características y beneficios, puede actualizar a una membresía de oro. Una membresía de oro cuesta $49 por año y te da acceso ilimitado a todas las lecciones, videos, rompecabezas, juegos, torneos y recompensas. También puede crear varias cuentas para niños bajo una cuenta principal. Puede actualizar a una membresía de oro haciendo clic en el botón "Actualizar" en el sitio web o la aplicación. </p>
|
31 |
-
<h3>Empieza a aprender y jugar al ajedrez con ChessKid</h3>
|
32 |
-
<p>Una vez que haya creado su cuenta y verificado su correo electrónico, puede comenzar a aprender y jugar al ajedrez con ChessKid. Puede elegir entre diferentes secciones en el sitio web o la aplicación, como Aprender, Jugar, Puzzles, Videos, Clubes, Torneos y Más. También puede personalizar su perfil, configuración y preferencias. Puede explorar todas las características y opciones de ChessKid a su propio ritmo y nivel. </p>
|
33 |
-
<h2>Conclusión</h2>
|
34 |
-
<p>ChessKid es la mejor aplicación de ajedrez para niños que quieren aprender y jugar al ajedrez de una manera divertida y fácil. Tiene muchas características y beneficios que lo hacen atractivo y educativo. También es seguro y de uso gratuito. Para descargar ChessKid, solo tienes que seguir estos sencillos pasos:</p>
|
35 |
-
<ul>
|
36 |
-
<li>Descargar ChessKid desde el sitio web oficial o tienda de aplicaciones</li>
|
37 |
-
<li>Crear una cuenta gratuita o actualizar a una membresía de oro</li>
|
38 |
-
<li>Empieza a aprender y jugar al ajedrez con ChessKid</li>
|
39 |
-
</ul>
|
40 |
-
<p>Entonces, ¿qué estás esperando? Descarga ChessKid hoy y comienza tu aventura de ajedrez con ChessKid.</p>
|
41 |
-
<h2>Preguntas frecuentes</h2>
|
42 |
-
<p>Aquí hay algunas preguntas y respuestas comunes sobre ChessKid:</p>
|
43 |
-
|
44 |
-
<p>A: Sí, ChessKid es 100% seguro para los niños. Tiene estrictas medidas de seguridad y políticas que protegen la privacidad y la seguridad de sus usuarios. Limita las opciones de chat y requiere el permiso de los padres para ciertas características. También monitorea y modera todos los contenidos y actividades de su plataforma. </p>
|
45 |
-
<h4>Q: ¿Es ChessKid realmente gratis para los niños? </h4>
|
46 |
-
<p>A: Sí, ChessKid es 100% gratis para los niños. Puede crear una cuenta gratuita y acceder a la mayoría de las funciones de ChessKid sin pagar nada. Sin embargo, si desea obtener más características y beneficios, puede actualizar a una membresía de oro por $ 49 por año. </p>
|
47 |
-
<h4>Q: ¿Cómo puedo contactar con el soporte de ChessKid? </h4>
|
48 |
-
<p>A: Si tiene alguna pregunta o problema con ChessKid, puede ponerse en contacto con el soporte de ChessKid enviándoles un correo electrónico a <a href="mailto:[email protected]">[email protected]</a>. También puede visitar su centro de ayuda en <a href="">https://support.chesskid.com/hc/en-us</a> para obtener más información y recursos. </p>
|
49 |
-
<h4>Q: ¿Cómo puedo eliminar mi cuenta de ChessKid? </h4>
|
50 |
-
<p>A: Si desea eliminar su cuenta de ChessKid, puede hacerlo iniciando sesión en su cuenta y yendo a la configuración de su perfil. También puedes enviar un correo electrónico al soporte de ChessKid a <a href="mailto:[email protected]">[email protected]</a> y pedirles que eliminen tu cuenta. Tenga en cuenta que la eliminación de su cuenta borrará todos sus datos y el progreso en ChessKid.</p>
|
51 |
-
<h4>P: ¿Cómo puedo obtener más estrellas, insignias, coronas y otras recompensas en ChessKid? </h4>
|
52 |
-
<p>A: Puedes obtener más estrellas, insignias, coronas y otras recompensas en ChessKid completando diferentes tareas y actividades. Por ejemplo, puedes conseguir estrellas resolviendo puzles, insignias viendo vídeos, coronas terminando clases y trofeos ganando torneos. También puedes obtener recompensas especiales participando en eventos y concursos. </p> 64aa2da5cf<br />
|
53 |
-
<br />
|
54 |
-
<br />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/botocore/vendored/six.py
DELETED
@@ -1,998 +0,0 @@
|
|
1 |
-
# Copyright (c) 2010-2020 Benjamin Peterson
|
2 |
-
#
|
3 |
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4 |
-
# of this software and associated documentation files (the "Software"), to deal
|
5 |
-
# in the Software without restriction, including without limitation the rights
|
6 |
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7 |
-
# copies of the Software, and to permit persons to whom the Software is
|
8 |
-
# furnished to do so, subject to the following conditions:
|
9 |
-
#
|
10 |
-
# The above copyright notice and this permission notice shall be included in all
|
11 |
-
# copies or substantial portions of the Software.
|
12 |
-
#
|
13 |
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14 |
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15 |
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16 |
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17 |
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18 |
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19 |
-
# SOFTWARE.
|
20 |
-
|
21 |
-
"""Utilities for writing code that runs on Python 2 and 3"""
|
22 |
-
|
23 |
-
from __future__ import absolute_import
|
24 |
-
|
25 |
-
import functools
|
26 |
-
import itertools
|
27 |
-
import operator
|
28 |
-
import sys
|
29 |
-
import types
|
30 |
-
|
31 |
-
__author__ = "Benjamin Peterson <[email protected]>"
|
32 |
-
__version__ = "1.16.0"
|
33 |
-
|
34 |
-
|
35 |
-
# Useful for very coarse version differentiation.
|
36 |
-
PY2 = sys.version_info[0] == 2
|
37 |
-
PY3 = sys.version_info[0] == 3
|
38 |
-
PY34 = sys.version_info[0:2] >= (3, 4)
|
39 |
-
|
40 |
-
if PY3:
|
41 |
-
string_types = str,
|
42 |
-
integer_types = int,
|
43 |
-
class_types = type,
|
44 |
-
text_type = str
|
45 |
-
binary_type = bytes
|
46 |
-
|
47 |
-
MAXSIZE = sys.maxsize
|
48 |
-
else:
|
49 |
-
string_types = basestring,
|
50 |
-
integer_types = (int, long)
|
51 |
-
class_types = (type, types.ClassType)
|
52 |
-
text_type = unicode
|
53 |
-
binary_type = str
|
54 |
-
|
55 |
-
if sys.platform.startswith("java"):
|
56 |
-
# Jython always uses 32 bits.
|
57 |
-
MAXSIZE = int((1 << 31) - 1)
|
58 |
-
else:
|
59 |
-
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
|
60 |
-
class X(object):
|
61 |
-
|
62 |
-
def __len__(self):
|
63 |
-
return 1 << 31
|
64 |
-
try:
|
65 |
-
len(X())
|
66 |
-
except OverflowError:
|
67 |
-
# 32-bit
|
68 |
-
MAXSIZE = int((1 << 31) - 1)
|
69 |
-
else:
|
70 |
-
# 64-bit
|
71 |
-
MAXSIZE = int((1 << 63) - 1)
|
72 |
-
del X
|
73 |
-
|
74 |
-
if PY34:
|
75 |
-
from importlib.util import spec_from_loader
|
76 |
-
else:
|
77 |
-
spec_from_loader = None
|
78 |
-
|
79 |
-
|
80 |
-
def _add_doc(func, doc):
|
81 |
-
"""Add documentation to a function."""
|
82 |
-
func.__doc__ = doc
|
83 |
-
|
84 |
-
|
85 |
-
def _import_module(name):
|
86 |
-
"""Import module, returning the module after the last dot."""
|
87 |
-
__import__(name)
|
88 |
-
return sys.modules[name]
|
89 |
-
|
90 |
-
|
91 |
-
class _LazyDescr(object):
|
92 |
-
|
93 |
-
def __init__(self, name):
|
94 |
-
self.name = name
|
95 |
-
|
96 |
-
def __get__(self, obj, tp):
|
97 |
-
result = self._resolve()
|
98 |
-
setattr(obj, self.name, result) # Invokes __set__.
|
99 |
-
try:
|
100 |
-
# This is a bit ugly, but it avoids running this again by
|
101 |
-
# removing this descriptor.
|
102 |
-
delattr(obj.__class__, self.name)
|
103 |
-
except AttributeError:
|
104 |
-
pass
|
105 |
-
return result
|
106 |
-
|
107 |
-
|
108 |
-
class MovedModule(_LazyDescr):
|
109 |
-
|
110 |
-
def __init__(self, name, old, new=None):
|
111 |
-
super(MovedModule, self).__init__(name)
|
112 |
-
if PY3:
|
113 |
-
if new is None:
|
114 |
-
new = name
|
115 |
-
self.mod = new
|
116 |
-
else:
|
117 |
-
self.mod = old
|
118 |
-
|
119 |
-
def _resolve(self):
|
120 |
-
return _import_module(self.mod)
|
121 |
-
|
122 |
-
def __getattr__(self, attr):
|
123 |
-
_module = self._resolve()
|
124 |
-
value = getattr(_module, attr)
|
125 |
-
setattr(self, attr, value)
|
126 |
-
return value
|
127 |
-
|
128 |
-
|
129 |
-
class _LazyModule(types.ModuleType):
|
130 |
-
|
131 |
-
def __init__(self, name):
|
132 |
-
super(_LazyModule, self).__init__(name)
|
133 |
-
self.__doc__ = self.__class__.__doc__
|
134 |
-
|
135 |
-
def __dir__(self):
|
136 |
-
attrs = ["__doc__", "__name__"]
|
137 |
-
attrs += [attr.name for attr in self._moved_attributes]
|
138 |
-
return attrs
|
139 |
-
|
140 |
-
# Subclasses should override this
|
141 |
-
_moved_attributes = []
|
142 |
-
|
143 |
-
|
144 |
-
class MovedAttribute(_LazyDescr):
|
145 |
-
|
146 |
-
def __init__(self, name, old_mod, new_mod, old_attr=None, new_attr=None):
|
147 |
-
super(MovedAttribute, self).__init__(name)
|
148 |
-
if PY3:
|
149 |
-
if new_mod is None:
|
150 |
-
new_mod = name
|
151 |
-
self.mod = new_mod
|
152 |
-
if new_attr is None:
|
153 |
-
if old_attr is None:
|
154 |
-
new_attr = name
|
155 |
-
else:
|
156 |
-
new_attr = old_attr
|
157 |
-
self.attr = new_attr
|
158 |
-
else:
|
159 |
-
self.mod = old_mod
|
160 |
-
if old_attr is None:
|
161 |
-
old_attr = name
|
162 |
-
self.attr = old_attr
|
163 |
-
|
164 |
-
def _resolve(self):
|
165 |
-
module = _import_module(self.mod)
|
166 |
-
return getattr(module, self.attr)
|
167 |
-
|
168 |
-
|
169 |
-
class _SixMetaPathImporter(object):
|
170 |
-
|
171 |
-
"""
|
172 |
-
A meta path importer to import six.moves and its submodules.
|
173 |
-
|
174 |
-
This class implements a PEP302 finder and loader. It should be compatible
|
175 |
-
with Python 2.5 and all existing versions of Python3
|
176 |
-
"""
|
177 |
-
|
178 |
-
def __init__(self, six_module_name):
|
179 |
-
self.name = six_module_name
|
180 |
-
self.known_modules = {}
|
181 |
-
|
182 |
-
def _add_module(self, mod, *fullnames):
|
183 |
-
for fullname in fullnames:
|
184 |
-
self.known_modules[self.name + "." + fullname] = mod
|
185 |
-
|
186 |
-
def _get_module(self, fullname):
|
187 |
-
return self.known_modules[self.name + "." + fullname]
|
188 |
-
|
189 |
-
def find_module(self, fullname, path=None):
|
190 |
-
if fullname in self.known_modules:
|
191 |
-
return self
|
192 |
-
return None
|
193 |
-
|
194 |
-
def find_spec(self, fullname, path, target=None):
|
195 |
-
if fullname in self.known_modules:
|
196 |
-
return spec_from_loader(fullname, self)
|
197 |
-
return None
|
198 |
-
|
199 |
-
def __get_module(self, fullname):
|
200 |
-
try:
|
201 |
-
return self.known_modules[fullname]
|
202 |
-
except KeyError:
|
203 |
-
raise ImportError("This loader does not know module " + fullname)
|
204 |
-
|
205 |
-
def load_module(self, fullname):
|
206 |
-
try:
|
207 |
-
# in case of a reload
|
208 |
-
return sys.modules[fullname]
|
209 |
-
except KeyError:
|
210 |
-
pass
|
211 |
-
mod = self.__get_module(fullname)
|
212 |
-
if isinstance(mod, MovedModule):
|
213 |
-
mod = mod._resolve()
|
214 |
-
else:
|
215 |
-
mod.__loader__ = self
|
216 |
-
sys.modules[fullname] = mod
|
217 |
-
return mod
|
218 |
-
|
219 |
-
def is_package(self, fullname):
|
220 |
-
"""
|
221 |
-
Return true, if the named module is a package.
|
222 |
-
|
223 |
-
We need this method to get correct spec objects with
|
224 |
-
Python 3.4 (see PEP451)
|
225 |
-
"""
|
226 |
-
return hasattr(self.__get_module(fullname), "__path__")
|
227 |
-
|
228 |
-
def get_code(self, fullname):
|
229 |
-
"""Return None
|
230 |
-
|
231 |
-
Required, if is_package is implemented"""
|
232 |
-
self.__get_module(fullname) # eventually raises ImportError
|
233 |
-
return None
|
234 |
-
get_source = get_code # same as get_code
|
235 |
-
|
236 |
-
def create_module(self, spec):
|
237 |
-
return self.load_module(spec.name)
|
238 |
-
|
239 |
-
def exec_module(self, module):
|
240 |
-
pass
|
241 |
-
|
242 |
-
_importer = _SixMetaPathImporter(__name__)
|
243 |
-
|
244 |
-
|
245 |
-
class _MovedItems(_LazyModule):
|
246 |
-
|
247 |
-
"""Lazy loading of moved objects"""
|
248 |
-
__path__ = [] # mark as package
|
249 |
-
|
250 |
-
|
251 |
-
_moved_attributes = [
|
252 |
-
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
|
253 |
-
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
|
254 |
-
MovedAttribute("filterfalse", "itertools", "itertools", "ifilterfalse", "filterfalse"),
|
255 |
-
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
|
256 |
-
MovedAttribute("intern", "__builtin__", "sys"),
|
257 |
-
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
|
258 |
-
MovedAttribute("getcwd", "os", "os", "getcwdu", "getcwd"),
|
259 |
-
MovedAttribute("getcwdb", "os", "os", "getcwd", "getcwdb"),
|
260 |
-
MovedAttribute("getoutput", "commands", "subprocess"),
|
261 |
-
MovedAttribute("range", "__builtin__", "builtins", "xrange", "range"),
|
262 |
-
MovedAttribute("reload_module", "__builtin__", "importlib" if PY34 else "imp", "reload"),
|
263 |
-
MovedAttribute("reduce", "__builtin__", "functools"),
|
264 |
-
MovedAttribute("shlex_quote", "pipes", "shlex", "quote"),
|
265 |
-
MovedAttribute("StringIO", "StringIO", "io"),
|
266 |
-
MovedAttribute("UserDict", "UserDict", "collections"),
|
267 |
-
MovedAttribute("UserList", "UserList", "collections"),
|
268 |
-
MovedAttribute("UserString", "UserString", "collections"),
|
269 |
-
MovedAttribute("xrange", "__builtin__", "builtins", "xrange", "range"),
|
270 |
-
MovedAttribute("zip", "itertools", "builtins", "izip", "zip"),
|
271 |
-
MovedAttribute("zip_longest", "itertools", "itertools", "izip_longest", "zip_longest"),
|
272 |
-
MovedModule("builtins", "__builtin__"),
|
273 |
-
MovedModule("configparser", "ConfigParser"),
|
274 |
-
MovedModule("collections_abc", "collections", "collections.abc" if sys.version_info >= (3, 3) else "collections"),
|
275 |
-
MovedModule("copyreg", "copy_reg"),
|
276 |
-
MovedModule("dbm_gnu", "gdbm", "dbm.gnu"),
|
277 |
-
MovedModule("dbm_ndbm", "dbm", "dbm.ndbm"),
|
278 |
-
MovedModule("_dummy_thread", "dummy_thread", "_dummy_thread" if sys.version_info < (3, 9) else "_thread"),
|
279 |
-
MovedModule("http_cookiejar", "cookielib", "http.cookiejar"),
|
280 |
-
MovedModule("http_cookies", "Cookie", "http.cookies"),
|
281 |
-
MovedModule("html_entities", "htmlentitydefs", "html.entities"),
|
282 |
-
MovedModule("html_parser", "HTMLParser", "html.parser"),
|
283 |
-
MovedModule("http_client", "httplib", "http.client"),
|
284 |
-
MovedModule("email_mime_base", "email.MIMEBase", "email.mime.base"),
|
285 |
-
MovedModule("email_mime_image", "email.MIMEImage", "email.mime.image"),
|
286 |
-
MovedModule("email_mime_multipart", "email.MIMEMultipart", "email.mime.multipart"),
|
287 |
-
MovedModule("email_mime_nonmultipart", "email.MIMENonMultipart", "email.mime.nonmultipart"),
|
288 |
-
MovedModule("email_mime_text", "email.MIMEText", "email.mime.text"),
|
289 |
-
MovedModule("BaseHTTPServer", "BaseHTTPServer", "http.server"),
|
290 |
-
MovedModule("CGIHTTPServer", "CGIHTTPServer", "http.server"),
|
291 |
-
MovedModule("SimpleHTTPServer", "SimpleHTTPServer", "http.server"),
|
292 |
-
MovedModule("cPickle", "cPickle", "pickle"),
|
293 |
-
MovedModule("queue", "Queue"),
|
294 |
-
MovedModule("reprlib", "repr"),
|
295 |
-
MovedModule("socketserver", "SocketServer"),
|
296 |
-
MovedModule("_thread", "thread", "_thread"),
|
297 |
-
MovedModule("tkinter", "Tkinter"),
|
298 |
-
MovedModule("tkinter_dialog", "Dialog", "tkinter.dialog"),
|
299 |
-
MovedModule("tkinter_filedialog", "FileDialog", "tkinter.filedialog"),
|
300 |
-
MovedModule("tkinter_scrolledtext", "ScrolledText", "tkinter.scrolledtext"),
|
301 |
-
MovedModule("tkinter_simpledialog", "SimpleDialog", "tkinter.simpledialog"),
|
302 |
-
MovedModule("tkinter_tix", "Tix", "tkinter.tix"),
|
303 |
-
MovedModule("tkinter_ttk", "ttk", "tkinter.ttk"),
|
304 |
-
MovedModule("tkinter_constants", "Tkconstants", "tkinter.constants"),
|
305 |
-
MovedModule("tkinter_dnd", "Tkdnd", "tkinter.dnd"),
|
306 |
-
MovedModule("tkinter_colorchooser", "tkColorChooser",
|
307 |
-
"tkinter.colorchooser"),
|
308 |
-
MovedModule("tkinter_commondialog", "tkCommonDialog",
|
309 |
-
"tkinter.commondialog"),
|
310 |
-
MovedModule("tkinter_tkfiledialog", "tkFileDialog", "tkinter.filedialog"),
|
311 |
-
MovedModule("tkinter_font", "tkFont", "tkinter.font"),
|
312 |
-
MovedModule("tkinter_messagebox", "tkMessageBox", "tkinter.messagebox"),
|
313 |
-
MovedModule("tkinter_tksimpledialog", "tkSimpleDialog",
|
314 |
-
"tkinter.simpledialog"),
|
315 |
-
MovedModule("urllib_parse", __name__ + ".moves.urllib_parse", "urllib.parse"),
|
316 |
-
MovedModule("urllib_error", __name__ + ".moves.urllib_error", "urllib.error"),
|
317 |
-
MovedModule("urllib", __name__ + ".moves.urllib", __name__ + ".moves.urllib"),
|
318 |
-
MovedModule("urllib_robotparser", "robotparser", "urllib.robotparser"),
|
319 |
-
MovedModule("xmlrpc_client", "xmlrpclib", "xmlrpc.client"),
|
320 |
-
MovedModule("xmlrpc_server", "SimpleXMLRPCServer", "xmlrpc.server"),
|
321 |
-
]
|
322 |
-
# Add windows specific modules.
|
323 |
-
if sys.platform == "win32":
|
324 |
-
_moved_attributes += [
|
325 |
-
MovedModule("winreg", "_winreg"),
|
326 |
-
]
|
327 |
-
|
328 |
-
for attr in _moved_attributes:
|
329 |
-
setattr(_MovedItems, attr.name, attr)
|
330 |
-
if isinstance(attr, MovedModule):
|
331 |
-
_importer._add_module(attr, "moves." + attr.name)
|
332 |
-
del attr
|
333 |
-
|
334 |
-
_MovedItems._moved_attributes = _moved_attributes
|
335 |
-
|
336 |
-
moves = _MovedItems(__name__ + ".moves")
|
337 |
-
_importer._add_module(moves, "moves")
|
338 |
-
|
339 |
-
|
340 |
-
class Module_six_moves_urllib_parse(_LazyModule):
|
341 |
-
|
342 |
-
"""Lazy loading of moved objects in six.moves.urllib_parse"""
|
343 |
-
|
344 |
-
|
345 |
-
_urllib_parse_moved_attributes = [
|
346 |
-
MovedAttribute("ParseResult", "urlparse", "urllib.parse"),
|
347 |
-
MovedAttribute("SplitResult", "urlparse", "urllib.parse"),
|
348 |
-
MovedAttribute("parse_qs", "urlparse", "urllib.parse"),
|
349 |
-
MovedAttribute("parse_qsl", "urlparse", "urllib.parse"),
|
350 |
-
MovedAttribute("urldefrag", "urlparse", "urllib.parse"),
|
351 |
-
MovedAttribute("urljoin", "urlparse", "urllib.parse"),
|
352 |
-
MovedAttribute("urlparse", "urlparse", "urllib.parse"),
|
353 |
-
MovedAttribute("urlsplit", "urlparse", "urllib.parse"),
|
354 |
-
MovedAttribute("urlunparse", "urlparse", "urllib.parse"),
|
355 |
-
MovedAttribute("urlunsplit", "urlparse", "urllib.parse"),
|
356 |
-
MovedAttribute("quote", "urllib", "urllib.parse"),
|
357 |
-
MovedAttribute("quote_plus", "urllib", "urllib.parse"),
|
358 |
-
MovedAttribute("unquote", "urllib", "urllib.parse"),
|
359 |
-
MovedAttribute("unquote_plus", "urllib", "urllib.parse"),
|
360 |
-
MovedAttribute("unquote_to_bytes", "urllib", "urllib.parse", "unquote", "unquote_to_bytes"),
|
361 |
-
MovedAttribute("urlencode", "urllib", "urllib.parse"),
|
362 |
-
MovedAttribute("splitquery", "urllib", "urllib.parse"),
|
363 |
-
MovedAttribute("splittag", "urllib", "urllib.parse"),
|
364 |
-
MovedAttribute("splituser", "urllib", "urllib.parse"),
|
365 |
-
MovedAttribute("splitvalue", "urllib", "urllib.parse"),
|
366 |
-
MovedAttribute("uses_fragment", "urlparse", "urllib.parse"),
|
367 |
-
MovedAttribute("uses_netloc", "urlparse", "urllib.parse"),
|
368 |
-
MovedAttribute("uses_params", "urlparse", "urllib.parse"),
|
369 |
-
MovedAttribute("uses_query", "urlparse", "urllib.parse"),
|
370 |
-
MovedAttribute("uses_relative", "urlparse", "urllib.parse"),
|
371 |
-
]
|
372 |
-
for attr in _urllib_parse_moved_attributes:
|
373 |
-
setattr(Module_six_moves_urllib_parse, attr.name, attr)
|
374 |
-
del attr
|
375 |
-
|
376 |
-
Module_six_moves_urllib_parse._moved_attributes = _urllib_parse_moved_attributes
|
377 |
-
|
378 |
-
_importer._add_module(Module_six_moves_urllib_parse(__name__ + ".moves.urllib_parse"),
|
379 |
-
"moves.urllib_parse", "moves.urllib.parse")
|
380 |
-
|
381 |
-
|
382 |
-
class Module_six_moves_urllib_error(_LazyModule):
|
383 |
-
|
384 |
-
"""Lazy loading of moved objects in six.moves.urllib_error"""
|
385 |
-
|
386 |
-
|
387 |
-
_urllib_error_moved_attributes = [
|
388 |
-
MovedAttribute("URLError", "urllib2", "urllib.error"),
|
389 |
-
MovedAttribute("HTTPError", "urllib2", "urllib.error"),
|
390 |
-
MovedAttribute("ContentTooShortError", "urllib", "urllib.error"),
|
391 |
-
]
|
392 |
-
for attr in _urllib_error_moved_attributes:
|
393 |
-
setattr(Module_six_moves_urllib_error, attr.name, attr)
|
394 |
-
del attr
|
395 |
-
|
396 |
-
Module_six_moves_urllib_error._moved_attributes = _urllib_error_moved_attributes
|
397 |
-
|
398 |
-
_importer._add_module(Module_six_moves_urllib_error(__name__ + ".moves.urllib.error"),
|
399 |
-
"moves.urllib_error", "moves.urllib.error")
|
400 |
-
|
401 |
-
|
402 |
-
class Module_six_moves_urllib_request(_LazyModule):
|
403 |
-
|
404 |
-
"""Lazy loading of moved objects in six.moves.urllib_request"""
|
405 |
-
|
406 |
-
|
407 |
-
_urllib_request_moved_attributes = [
|
408 |
-
MovedAttribute("urlopen", "urllib2", "urllib.request"),
|
409 |
-
MovedAttribute("install_opener", "urllib2", "urllib.request"),
|
410 |
-
MovedAttribute("build_opener", "urllib2", "urllib.request"),
|
411 |
-
MovedAttribute("pathname2url", "urllib", "urllib.request"),
|
412 |
-
MovedAttribute("url2pathname", "urllib", "urllib.request"),
|
413 |
-
MovedAttribute("getproxies", "urllib", "urllib.request"),
|
414 |
-
MovedAttribute("Request", "urllib2", "urllib.request"),
|
415 |
-
MovedAttribute("OpenerDirector", "urllib2", "urllib.request"),
|
416 |
-
MovedAttribute("HTTPDefaultErrorHandler", "urllib2", "urllib.request"),
|
417 |
-
MovedAttribute("HTTPRedirectHandler", "urllib2", "urllib.request"),
|
418 |
-
MovedAttribute("HTTPCookieProcessor", "urllib2", "urllib.request"),
|
419 |
-
MovedAttribute("ProxyHandler", "urllib2", "urllib.request"),
|
420 |
-
MovedAttribute("BaseHandler", "urllib2", "urllib.request"),
|
421 |
-
MovedAttribute("HTTPPasswordMgr", "urllib2", "urllib.request"),
|
422 |
-
MovedAttribute("HTTPPasswordMgrWithDefaultRealm", "urllib2", "urllib.request"),
|
423 |
-
MovedAttribute("AbstractBasicAuthHandler", "urllib2", "urllib.request"),
|
424 |
-
MovedAttribute("HTTPBasicAuthHandler", "urllib2", "urllib.request"),
|
425 |
-
MovedAttribute("ProxyBasicAuthHandler", "urllib2", "urllib.request"),
|
426 |
-
MovedAttribute("AbstractDigestAuthHandler", "urllib2", "urllib.request"),
|
427 |
-
MovedAttribute("HTTPDigestAuthHandler", "urllib2", "urllib.request"),
|
428 |
-
MovedAttribute("ProxyDigestAuthHandler", "urllib2", "urllib.request"),
|
429 |
-
MovedAttribute("HTTPHandler", "urllib2", "urllib.request"),
|
430 |
-
MovedAttribute("HTTPSHandler", "urllib2", "urllib.request"),
|
431 |
-
MovedAttribute("FileHandler", "urllib2", "urllib.request"),
|
432 |
-
MovedAttribute("FTPHandler", "urllib2", "urllib.request"),
|
433 |
-
MovedAttribute("CacheFTPHandler", "urllib2", "urllib.request"),
|
434 |
-
MovedAttribute("UnknownHandler", "urllib2", "urllib.request"),
|
435 |
-
MovedAttribute("HTTPErrorProcessor", "urllib2", "urllib.request"),
|
436 |
-
MovedAttribute("urlretrieve", "urllib", "urllib.request"),
|
437 |
-
MovedAttribute("urlcleanup", "urllib", "urllib.request"),
|
438 |
-
MovedAttribute("URLopener", "urllib", "urllib.request"),
|
439 |
-
MovedAttribute("FancyURLopener", "urllib", "urllib.request"),
|
440 |
-
MovedAttribute("proxy_bypass", "urllib", "urllib.request"),
|
441 |
-
MovedAttribute("parse_http_list", "urllib2", "urllib.request"),
|
442 |
-
MovedAttribute("parse_keqv_list", "urllib2", "urllib.request"),
|
443 |
-
]
|
444 |
-
for attr in _urllib_request_moved_attributes:
|
445 |
-
setattr(Module_six_moves_urllib_request, attr.name, attr)
|
446 |
-
del attr
|
447 |
-
|
448 |
-
Module_six_moves_urllib_request._moved_attributes = _urllib_request_moved_attributes
|
449 |
-
|
450 |
-
_importer._add_module(Module_six_moves_urllib_request(__name__ + ".moves.urllib.request"),
|
451 |
-
"moves.urllib_request", "moves.urllib.request")
|
452 |
-
|
453 |
-
|
454 |
-
class Module_six_moves_urllib_response(_LazyModule):
|
455 |
-
|
456 |
-
"""Lazy loading of moved objects in six.moves.urllib_response"""
|
457 |
-
|
458 |
-
|
459 |
-
_urllib_response_moved_attributes = [
|
460 |
-
MovedAttribute("addbase", "urllib", "urllib.response"),
|
461 |
-
MovedAttribute("addclosehook", "urllib", "urllib.response"),
|
462 |
-
MovedAttribute("addinfo", "urllib", "urllib.response"),
|
463 |
-
MovedAttribute("addinfourl", "urllib", "urllib.response"),
|
464 |
-
]
|
465 |
-
for attr in _urllib_response_moved_attributes:
|
466 |
-
setattr(Module_six_moves_urllib_response, attr.name, attr)
|
467 |
-
del attr
|
468 |
-
|
469 |
-
Module_six_moves_urllib_response._moved_attributes = _urllib_response_moved_attributes
|
470 |
-
|
471 |
-
_importer._add_module(Module_six_moves_urllib_response(__name__ + ".moves.urllib.response"),
|
472 |
-
"moves.urllib_response", "moves.urllib.response")
|
473 |
-
|
474 |
-
|
475 |
-
class Module_six_moves_urllib_robotparser(_LazyModule):
|
476 |
-
|
477 |
-
"""Lazy loading of moved objects in six.moves.urllib_robotparser"""
|
478 |
-
|
479 |
-
|
480 |
-
_urllib_robotparser_moved_attributes = [
|
481 |
-
MovedAttribute("RobotFileParser", "robotparser", "urllib.robotparser"),
|
482 |
-
]
|
483 |
-
for attr in _urllib_robotparser_moved_attributes:
|
484 |
-
setattr(Module_six_moves_urllib_robotparser, attr.name, attr)
|
485 |
-
del attr
|
486 |
-
|
487 |
-
Module_six_moves_urllib_robotparser._moved_attributes = _urllib_robotparser_moved_attributes
|
488 |
-
|
489 |
-
_importer._add_module(Module_six_moves_urllib_robotparser(__name__ + ".moves.urllib.robotparser"),
|
490 |
-
"moves.urllib_robotparser", "moves.urllib.robotparser")
|
491 |
-
|
492 |
-
|
493 |
-
class Module_six_moves_urllib(types.ModuleType):
|
494 |
-
|
495 |
-
"""Create a six.moves.urllib namespace that resembles the Python 3 namespace"""
|
496 |
-
__path__ = [] # mark as package
|
497 |
-
parse = _importer._get_module("moves.urllib_parse")
|
498 |
-
error = _importer._get_module("moves.urllib_error")
|
499 |
-
request = _importer._get_module("moves.urllib_request")
|
500 |
-
response = _importer._get_module("moves.urllib_response")
|
501 |
-
robotparser = _importer._get_module("moves.urllib_robotparser")
|
502 |
-
|
503 |
-
def __dir__(self):
|
504 |
-
return ['parse', 'error', 'request', 'response', 'robotparser']
|
505 |
-
|
506 |
-
_importer._add_module(Module_six_moves_urllib(__name__ + ".moves.urllib"),
|
507 |
-
"moves.urllib")
|
508 |
-
|
509 |
-
|
510 |
-
def add_move(move):
|
511 |
-
"""Add an item to six.moves."""
|
512 |
-
setattr(_MovedItems, move.name, move)
|
513 |
-
|
514 |
-
|
515 |
-
def remove_move(name):
|
516 |
-
"""Remove item from six.moves."""
|
517 |
-
try:
|
518 |
-
delattr(_MovedItems, name)
|
519 |
-
except AttributeError:
|
520 |
-
try:
|
521 |
-
del moves.__dict__[name]
|
522 |
-
except KeyError:
|
523 |
-
raise AttributeError("no such move, %r" % (name,))
|
524 |
-
|
525 |
-
|
526 |
-
if PY3:
|
527 |
-
_meth_func = "__func__"
|
528 |
-
_meth_self = "__self__"
|
529 |
-
|
530 |
-
_func_closure = "__closure__"
|
531 |
-
_func_code = "__code__"
|
532 |
-
_func_defaults = "__defaults__"
|
533 |
-
_func_globals = "__globals__"
|
534 |
-
else:
|
535 |
-
_meth_func = "im_func"
|
536 |
-
_meth_self = "im_self"
|
537 |
-
|
538 |
-
_func_closure = "func_closure"
|
539 |
-
_func_code = "func_code"
|
540 |
-
_func_defaults = "func_defaults"
|
541 |
-
_func_globals = "func_globals"
|
542 |
-
|
543 |
-
|
544 |
-
try:
|
545 |
-
advance_iterator = next
|
546 |
-
except NameError:
|
547 |
-
def advance_iterator(it):
|
548 |
-
return it.next()
|
549 |
-
next = advance_iterator
|
550 |
-
|
551 |
-
|
552 |
-
try:
|
553 |
-
callable = callable
|
554 |
-
except NameError:
|
555 |
-
def callable(obj):
|
556 |
-
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
|
557 |
-
|
558 |
-
|
559 |
-
if PY3:
|
560 |
-
def get_unbound_function(unbound):
|
561 |
-
return unbound
|
562 |
-
|
563 |
-
create_bound_method = types.MethodType
|
564 |
-
|
565 |
-
def create_unbound_method(func, cls):
|
566 |
-
return func
|
567 |
-
|
568 |
-
Iterator = object
|
569 |
-
else:
|
570 |
-
def get_unbound_function(unbound):
|
571 |
-
return unbound.im_func
|
572 |
-
|
573 |
-
def create_bound_method(func, obj):
|
574 |
-
return types.MethodType(func, obj, obj.__class__)
|
575 |
-
|
576 |
-
def create_unbound_method(func, cls):
|
577 |
-
return types.MethodType(func, None, cls)
|
578 |
-
|
579 |
-
class Iterator(object):
|
580 |
-
|
581 |
-
def next(self):
|
582 |
-
return type(self).__next__(self)
|
583 |
-
|
584 |
-
callable = callable
|
585 |
-
_add_doc(get_unbound_function,
|
586 |
-
"""Get the function out of a possibly unbound function""")
|
587 |
-
|
588 |
-
|
589 |
-
get_method_function = operator.attrgetter(_meth_func)
|
590 |
-
get_method_self = operator.attrgetter(_meth_self)
|
591 |
-
get_function_closure = operator.attrgetter(_func_closure)
|
592 |
-
get_function_code = operator.attrgetter(_func_code)
|
593 |
-
get_function_defaults = operator.attrgetter(_func_defaults)
|
594 |
-
get_function_globals = operator.attrgetter(_func_globals)
|
595 |
-
|
596 |
-
|
597 |
-
if PY3:
|
598 |
-
def iterkeys(d, **kw):
|
599 |
-
return iter(d.keys(**kw))
|
600 |
-
|
601 |
-
def itervalues(d, **kw):
|
602 |
-
return iter(d.values(**kw))
|
603 |
-
|
604 |
-
def iteritems(d, **kw):
|
605 |
-
return iter(d.items(**kw))
|
606 |
-
|
607 |
-
def iterlists(d, **kw):
|
608 |
-
return iter(d.lists(**kw))
|
609 |
-
|
610 |
-
viewkeys = operator.methodcaller("keys")
|
611 |
-
|
612 |
-
viewvalues = operator.methodcaller("values")
|
613 |
-
|
614 |
-
viewitems = operator.methodcaller("items")
|
615 |
-
else:
|
616 |
-
def iterkeys(d, **kw):
|
617 |
-
return d.iterkeys(**kw)
|
618 |
-
|
619 |
-
def itervalues(d, **kw):
|
620 |
-
return d.itervalues(**kw)
|
621 |
-
|
622 |
-
def iteritems(d, **kw):
|
623 |
-
return d.iteritems(**kw)
|
624 |
-
|
625 |
-
def iterlists(d, **kw):
|
626 |
-
return d.iterlists(**kw)
|
627 |
-
|
628 |
-
viewkeys = operator.methodcaller("viewkeys")
|
629 |
-
|
630 |
-
viewvalues = operator.methodcaller("viewvalues")
|
631 |
-
|
632 |
-
viewitems = operator.methodcaller("viewitems")
|
633 |
-
|
634 |
-
_add_doc(iterkeys, "Return an iterator over the keys of a dictionary.")
|
635 |
-
_add_doc(itervalues, "Return an iterator over the values of a dictionary.")
|
636 |
-
_add_doc(iteritems,
|
637 |
-
"Return an iterator over the (key, value) pairs of a dictionary.")
|
638 |
-
_add_doc(iterlists,
|
639 |
-
"Return an iterator over the (key, [values]) pairs of a dictionary.")
|
640 |
-
|
641 |
-
|
642 |
-
if PY3:
|
643 |
-
def b(s):
|
644 |
-
return s.encode("latin-1")
|
645 |
-
|
646 |
-
def u(s):
|
647 |
-
return s
|
648 |
-
unichr = chr
|
649 |
-
import struct
|
650 |
-
int2byte = struct.Struct(">B").pack
|
651 |
-
del struct
|
652 |
-
byte2int = operator.itemgetter(0)
|
653 |
-
indexbytes = operator.getitem
|
654 |
-
iterbytes = iter
|
655 |
-
import io
|
656 |
-
StringIO = io.StringIO
|
657 |
-
BytesIO = io.BytesIO
|
658 |
-
del io
|
659 |
-
_assertCountEqual = "assertCountEqual"
|
660 |
-
if sys.version_info[1] <= 1:
|
661 |
-
_assertRaisesRegex = "assertRaisesRegexp"
|
662 |
-
_assertRegex = "assertRegexpMatches"
|
663 |
-
_assertNotRegex = "assertNotRegexpMatches"
|
664 |
-
else:
|
665 |
-
_assertRaisesRegex = "assertRaisesRegex"
|
666 |
-
_assertRegex = "assertRegex"
|
667 |
-
_assertNotRegex = "assertNotRegex"
|
668 |
-
else:
|
669 |
-
def b(s):
|
670 |
-
return s
|
671 |
-
# Workaround for standalone backslash
|
672 |
-
|
673 |
-
def u(s):
|
674 |
-
return unicode(s.replace(r'\\', r'\\\\'), "unicode_escape")
|
675 |
-
unichr = unichr
|
676 |
-
int2byte = chr
|
677 |
-
|
678 |
-
def byte2int(bs):
|
679 |
-
return ord(bs[0])
|
680 |
-
|
681 |
-
def indexbytes(buf, i):
|
682 |
-
return ord(buf[i])
|
683 |
-
iterbytes = functools.partial(itertools.imap, ord)
|
684 |
-
import StringIO
|
685 |
-
StringIO = BytesIO = StringIO.StringIO
|
686 |
-
_assertCountEqual = "assertItemsEqual"
|
687 |
-
_assertRaisesRegex = "assertRaisesRegexp"
|
688 |
-
_assertRegex = "assertRegexpMatches"
|
689 |
-
_assertNotRegex = "assertNotRegexpMatches"
|
690 |
-
_add_doc(b, """Byte literal""")
|
691 |
-
_add_doc(u, """Text literal""")
|
692 |
-
|
693 |
-
|
694 |
-
def assertCountEqual(self, *args, **kwargs):
|
695 |
-
return getattr(self, _assertCountEqual)(*args, **kwargs)
|
696 |
-
|
697 |
-
|
698 |
-
def assertRaisesRegex(self, *args, **kwargs):
|
699 |
-
return getattr(self, _assertRaisesRegex)(*args, **kwargs)
|
700 |
-
|
701 |
-
|
702 |
-
def assertRegex(self, *args, **kwargs):
|
703 |
-
return getattr(self, _assertRegex)(*args, **kwargs)
|
704 |
-
|
705 |
-
|
706 |
-
def assertNotRegex(self, *args, **kwargs):
|
707 |
-
return getattr(self, _assertNotRegex)(*args, **kwargs)
|
708 |
-
|
709 |
-
|
710 |
-
if PY3:
|
711 |
-
exec_ = getattr(moves.builtins, "exec")
|
712 |
-
|
713 |
-
def reraise(tp, value, tb=None):
|
714 |
-
try:
|
715 |
-
if value is None:
|
716 |
-
value = tp()
|
717 |
-
if value.__traceback__ is not tb:
|
718 |
-
raise value.with_traceback(tb)
|
719 |
-
raise value
|
720 |
-
finally:
|
721 |
-
value = None
|
722 |
-
tb = None
|
723 |
-
|
724 |
-
else:
|
725 |
-
def exec_(_code_, _globs_=None, _locs_=None):
|
726 |
-
"""Execute code in a namespace."""
|
727 |
-
if _globs_ is None:
|
728 |
-
frame = sys._getframe(1)
|
729 |
-
_globs_ = frame.f_globals
|
730 |
-
if _locs_ is None:
|
731 |
-
_locs_ = frame.f_locals
|
732 |
-
del frame
|
733 |
-
elif _locs_ is None:
|
734 |
-
_locs_ = _globs_
|
735 |
-
exec("""exec _code_ in _globs_, _locs_""")
|
736 |
-
|
737 |
-
exec_("""def reraise(tp, value, tb=None):
|
738 |
-
try:
|
739 |
-
raise tp, value, tb
|
740 |
-
finally:
|
741 |
-
tb = None
|
742 |
-
""")
|
743 |
-
|
744 |
-
|
745 |
-
if sys.version_info[:2] > (3,):
|
746 |
-
exec_("""def raise_from(value, from_value):
|
747 |
-
try:
|
748 |
-
raise value from from_value
|
749 |
-
finally:
|
750 |
-
value = None
|
751 |
-
""")
|
752 |
-
else:
|
753 |
-
def raise_from(value, from_value):
|
754 |
-
raise value
|
755 |
-
|
756 |
-
|
757 |
-
print_ = getattr(moves.builtins, "print", None)
|
758 |
-
if print_ is None:
|
759 |
-
def print_(*args, **kwargs):
|
760 |
-
"""The new-style print function for Python 2.4 and 2.5."""
|
761 |
-
fp = kwargs.pop("file", sys.stdout)
|
762 |
-
if fp is None:
|
763 |
-
return
|
764 |
-
|
765 |
-
def write(data):
|
766 |
-
if not isinstance(data, basestring):
|
767 |
-
data = str(data)
|
768 |
-
# If the file has an encoding, encode unicode with it.
|
769 |
-
if (isinstance(fp, file) and
|
770 |
-
isinstance(data, unicode) and
|
771 |
-
fp.encoding is not None):
|
772 |
-
errors = getattr(fp, "errors", None)
|
773 |
-
if errors is None:
|
774 |
-
errors = "strict"
|
775 |
-
data = data.encode(fp.encoding, errors)
|
776 |
-
fp.write(data)
|
777 |
-
want_unicode = False
|
778 |
-
sep = kwargs.pop("sep", None)
|
779 |
-
if sep is not None:
|
780 |
-
if isinstance(sep, unicode):
|
781 |
-
want_unicode = True
|
782 |
-
elif not isinstance(sep, str):
|
783 |
-
raise TypeError("sep must be None or a string")
|
784 |
-
end = kwargs.pop("end", None)
|
785 |
-
if end is not None:
|
786 |
-
if isinstance(end, unicode):
|
787 |
-
want_unicode = True
|
788 |
-
elif not isinstance(end, str):
|
789 |
-
raise TypeError("end must be None or a string")
|
790 |
-
if kwargs:
|
791 |
-
raise TypeError("invalid keyword arguments to print()")
|
792 |
-
if not want_unicode:
|
793 |
-
for arg in args:
|
794 |
-
if isinstance(arg, unicode):
|
795 |
-
want_unicode = True
|
796 |
-
break
|
797 |
-
if want_unicode:
|
798 |
-
newline = unicode("\n")
|
799 |
-
space = unicode(" ")
|
800 |
-
else:
|
801 |
-
newline = "\n"
|
802 |
-
space = " "
|
803 |
-
if sep is None:
|
804 |
-
sep = space
|
805 |
-
if end is None:
|
806 |
-
end = newline
|
807 |
-
for i, arg in enumerate(args):
|
808 |
-
if i:
|
809 |
-
write(sep)
|
810 |
-
write(arg)
|
811 |
-
write(end)
|
812 |
-
if sys.version_info[:2] < (3, 3):
|
813 |
-
_print = print_
|
814 |
-
|
815 |
-
def print_(*args, **kwargs):
|
816 |
-
fp = kwargs.get("file", sys.stdout)
|
817 |
-
flush = kwargs.pop("flush", False)
|
818 |
-
_print(*args, **kwargs)
|
819 |
-
if flush and fp is not None:
|
820 |
-
fp.flush()
|
821 |
-
|
822 |
-
_add_doc(reraise, """Reraise an exception.""")
|
823 |
-
|
824 |
-
if sys.version_info[0:2] < (3, 4):
|
825 |
-
# This does exactly the same what the :func:`py3:functools.update_wrapper`
|
826 |
-
# function does on Python versions after 3.2. It sets the ``__wrapped__``
|
827 |
-
# attribute on ``wrapper`` object and it doesn't raise an error if any of
|
828 |
-
# the attributes mentioned in ``assigned`` and ``updated`` are missing on
|
829 |
-
# ``wrapped`` object.
|
830 |
-
def _update_wrapper(wrapper, wrapped,
|
831 |
-
assigned=functools.WRAPPER_ASSIGNMENTS,
|
832 |
-
updated=functools.WRAPPER_UPDATES):
|
833 |
-
for attr in assigned:
|
834 |
-
try:
|
835 |
-
value = getattr(wrapped, attr)
|
836 |
-
except AttributeError:
|
837 |
-
continue
|
838 |
-
else:
|
839 |
-
setattr(wrapper, attr, value)
|
840 |
-
for attr in updated:
|
841 |
-
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
|
842 |
-
wrapper.__wrapped__ = wrapped
|
843 |
-
return wrapper
|
844 |
-
_update_wrapper.__doc__ = functools.update_wrapper.__doc__
|
845 |
-
|
846 |
-
def wraps(wrapped, assigned=functools.WRAPPER_ASSIGNMENTS,
|
847 |
-
updated=functools.WRAPPER_UPDATES):
|
848 |
-
return functools.partial(_update_wrapper, wrapped=wrapped,
|
849 |
-
assigned=assigned, updated=updated)
|
850 |
-
wraps.__doc__ = functools.wraps.__doc__
|
851 |
-
|
852 |
-
else:
|
853 |
-
wraps = functools.wraps
|
854 |
-
|
855 |
-
|
856 |
-
def with_metaclass(meta, *bases):
|
857 |
-
"""Create a base class with a metaclass."""
|
858 |
-
# This requires a bit of explanation: the basic idea is to make a dummy
|
859 |
-
# metaclass for one level of class instantiation that replaces itself with
|
860 |
-
# the actual metaclass.
|
861 |
-
class metaclass(type):
|
862 |
-
|
863 |
-
def __new__(cls, name, this_bases, d):
|
864 |
-
if sys.version_info[:2] >= (3, 7):
|
865 |
-
# This version introduced PEP 560 that requires a bit
|
866 |
-
# of extra care (we mimic what is done by __build_class__).
|
867 |
-
resolved_bases = types.resolve_bases(bases)
|
868 |
-
if resolved_bases is not bases:
|
869 |
-
d['__orig_bases__'] = bases
|
870 |
-
else:
|
871 |
-
resolved_bases = bases
|
872 |
-
return meta(name, resolved_bases, d)
|
873 |
-
|
874 |
-
@classmethod
|
875 |
-
def __prepare__(cls, name, this_bases):
|
876 |
-
return meta.__prepare__(name, bases)
|
877 |
-
return type.__new__(metaclass, 'temporary_class', (), {})
|
878 |
-
|
879 |
-
|
880 |
-
def add_metaclass(metaclass):
|
881 |
-
"""Class decorator for creating a class with a metaclass."""
|
882 |
-
def wrapper(cls):
|
883 |
-
orig_vars = cls.__dict__.copy()
|
884 |
-
slots = orig_vars.get('__slots__')
|
885 |
-
if slots is not None:
|
886 |
-
if isinstance(slots, str):
|
887 |
-
slots = [slots]
|
888 |
-
for slots_var in slots:
|
889 |
-
orig_vars.pop(slots_var)
|
890 |
-
orig_vars.pop('__dict__', None)
|
891 |
-
orig_vars.pop('__weakref__', None)
|
892 |
-
if hasattr(cls, '__qualname__'):
|
893 |
-
orig_vars['__qualname__'] = cls.__qualname__
|
894 |
-
return metaclass(cls.__name__, cls.__bases__, orig_vars)
|
895 |
-
return wrapper
|
896 |
-
|
897 |
-
|
898 |
-
def ensure_binary(s, encoding='utf-8', errors='strict'):
|
899 |
-
"""Coerce **s** to six.binary_type.
|
900 |
-
|
901 |
-
For Python 2:
|
902 |
-
- `unicode` -> encoded to `str`
|
903 |
-
- `str` -> `str`
|
904 |
-
|
905 |
-
For Python 3:
|
906 |
-
- `str` -> encoded to `bytes`
|
907 |
-
- `bytes` -> `bytes`
|
908 |
-
"""
|
909 |
-
if isinstance(s, binary_type):
|
910 |
-
return s
|
911 |
-
if isinstance(s, text_type):
|
912 |
-
return s.encode(encoding, errors)
|
913 |
-
raise TypeError("not expecting type '%s'" % type(s))
|
914 |
-
|
915 |
-
|
916 |
-
def ensure_str(s, encoding='utf-8', errors='strict'):
|
917 |
-
"""Coerce *s* to `str`.
|
918 |
-
|
919 |
-
For Python 2:
|
920 |
-
- `unicode` -> encoded to `str`
|
921 |
-
- `str` -> `str`
|
922 |
-
|
923 |
-
For Python 3:
|
924 |
-
- `str` -> `str`
|
925 |
-
- `bytes` -> decoded to `str`
|
926 |
-
"""
|
927 |
-
# Optimization: Fast return for the common case.
|
928 |
-
if type(s) is str:
|
929 |
-
return s
|
930 |
-
if PY2 and isinstance(s, text_type):
|
931 |
-
return s.encode(encoding, errors)
|
932 |
-
elif PY3 and isinstance(s, binary_type):
|
933 |
-
return s.decode(encoding, errors)
|
934 |
-
elif not isinstance(s, (text_type, binary_type)):
|
935 |
-
raise TypeError("not expecting type '%s'" % type(s))
|
936 |
-
return s
|
937 |
-
|
938 |
-
|
939 |
-
def ensure_text(s, encoding='utf-8', errors='strict'):
|
940 |
-
"""Coerce *s* to six.text_type.
|
941 |
-
|
942 |
-
For Python 2:
|
943 |
-
- `unicode` -> `unicode`
|
944 |
-
- `str` -> `unicode`
|
945 |
-
|
946 |
-
For Python 3:
|
947 |
-
- `str` -> `str`
|
948 |
-
- `bytes` -> decoded to `str`
|
949 |
-
"""
|
950 |
-
if isinstance(s, binary_type):
|
951 |
-
return s.decode(encoding, errors)
|
952 |
-
elif isinstance(s, text_type):
|
953 |
-
return s
|
954 |
-
else:
|
955 |
-
raise TypeError("not expecting type '%s'" % type(s))
|
956 |
-
|
957 |
-
|
958 |
-
def python_2_unicode_compatible(klass):
|
959 |
-
"""
|
960 |
-
A class decorator that defines __unicode__ and __str__ methods under Python 2.
|
961 |
-
Under Python 3 it does nothing.
|
962 |
-
|
963 |
-
To support Python 2 and 3 with a single code base, define a __str__ method
|
964 |
-
returning text and apply this decorator to the class.
|
965 |
-
"""
|
966 |
-
if PY2:
|
967 |
-
if '__str__' not in klass.__dict__:
|
968 |
-
raise ValueError("@python_2_unicode_compatible cannot be applied "
|
969 |
-
"to %s because it doesn't define __str__()." %
|
970 |
-
klass.__name__)
|
971 |
-
klass.__unicode__ = klass.__str__
|
972 |
-
klass.__str__ = lambda self: self.__unicode__().encode('utf-8')
|
973 |
-
return klass
|
974 |
-
|
975 |
-
|
976 |
-
# Complete the moves implementation.
|
977 |
-
# This code is at the end of this module to speed up module loading.
|
978 |
-
# Turn this module into a package.
|
979 |
-
__path__ = [] # required for PEP 302 and PEP 451
|
980 |
-
__package__ = __name__ # see PEP 366 @ReservedAssignment
|
981 |
-
if globals().get("__spec__") is not None:
|
982 |
-
__spec__.submodule_search_locations = [] # PEP 451 @UndefinedVariable
|
983 |
-
# Remove other six meta path importers, since they cause problems. This can
|
984 |
-
# happen if six is removed from sys.modules and then reloaded. (Setuptools does
|
985 |
-
# this for some reason.)
|
986 |
-
if sys.meta_path:
|
987 |
-
for i, importer in enumerate(sys.meta_path):
|
988 |
-
# Here's some real nastiness: Another "instance" of the six module might
|
989 |
-
# be floating around. Therefore, we can't use isinstance() to check for
|
990 |
-
# the six meta path importer, since the other six instance will have
|
991 |
-
# inserted an importer with different class.
|
992 |
-
if (type(importer).__name__ == "_SixMetaPathImporter" and
|
993 |
-
importer.name == __name__):
|
994 |
-
del sys.meta_path[i]
|
995 |
-
break
|
996 |
-
del i, importer
|
997 |
-
# Finally, add the importer to the meta path import hook.
|
998 |
-
sys.meta_path.append(_importer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_internal/resolution/resolvelib/provider.py
DELETED
@@ -1,255 +0,0 @@
|
|
1 |
-
import collections
|
2 |
-
import math
|
3 |
-
from typing import (
|
4 |
-
TYPE_CHECKING,
|
5 |
-
Dict,
|
6 |
-
Iterable,
|
7 |
-
Iterator,
|
8 |
-
Mapping,
|
9 |
-
Sequence,
|
10 |
-
TypeVar,
|
11 |
-
Union,
|
12 |
-
)
|
13 |
-
|
14 |
-
from pip._vendor.resolvelib.providers import AbstractProvider
|
15 |
-
|
16 |
-
from .base import Candidate, Constraint, Requirement
|
17 |
-
from .candidates import REQUIRES_PYTHON_IDENTIFIER
|
18 |
-
from .factory import Factory
|
19 |
-
|
20 |
-
if TYPE_CHECKING:
|
21 |
-
from pip._vendor.resolvelib.providers import Preference
|
22 |
-
from pip._vendor.resolvelib.resolvers import RequirementInformation
|
23 |
-
|
24 |
-
PreferenceInformation = RequirementInformation[Requirement, Candidate]
|
25 |
-
|
26 |
-
_ProviderBase = AbstractProvider[Requirement, Candidate, str]
|
27 |
-
else:
|
28 |
-
_ProviderBase = AbstractProvider
|
29 |
-
|
30 |
-
# Notes on the relationship between the provider, the factory, and the
|
31 |
-
# candidate and requirement classes.
|
32 |
-
#
|
33 |
-
# The provider is a direct implementation of the resolvelib class. Its role
|
34 |
-
# is to deliver the API that resolvelib expects.
|
35 |
-
#
|
36 |
-
# Rather than work with completely abstract "requirement" and "candidate"
|
37 |
-
# concepts as resolvelib does, pip has concrete classes implementing these two
|
38 |
-
# ideas. The API of Requirement and Candidate objects are defined in the base
|
39 |
-
# classes, but essentially map fairly directly to the equivalent provider
|
40 |
-
# methods. In particular, `find_matches` and `is_satisfied_by` are
|
41 |
-
# requirement methods, and `get_dependencies` is a candidate method.
|
42 |
-
#
|
43 |
-
# The factory is the interface to pip's internal mechanisms. It is stateless,
|
44 |
-
# and is created by the resolver and held as a property of the provider. It is
|
45 |
-
# responsible for creating Requirement and Candidate objects, and provides
|
46 |
-
# services to those objects (access to pip's finder and preparer).
|
47 |
-
|
48 |
-
|
49 |
-
D = TypeVar("D")
|
50 |
-
V = TypeVar("V")
|
51 |
-
|
52 |
-
|
53 |
-
def _get_with_identifier(
|
54 |
-
mapping: Mapping[str, V],
|
55 |
-
identifier: str,
|
56 |
-
default: D,
|
57 |
-
) -> Union[D, V]:
|
58 |
-
"""Get item from a package name lookup mapping with a resolver identifier.
|
59 |
-
|
60 |
-
This extra logic is needed when the target mapping is keyed by package
|
61 |
-
name, which cannot be directly looked up with an identifier (which may
|
62 |
-
contain requested extras). Additional logic is added to also look up a value
|
63 |
-
by "cleaning up" the extras from the identifier.
|
64 |
-
"""
|
65 |
-
if identifier in mapping:
|
66 |
-
return mapping[identifier]
|
67 |
-
# HACK: Theoretically we should check whether this identifier is a valid
|
68 |
-
# "NAME[EXTRAS]" format, and parse out the name part with packaging or
|
69 |
-
# some regular expression. But since pip's resolver only spits out three
|
70 |
-
# kinds of identifiers: normalized PEP 503 names, normalized names plus
|
71 |
-
# extras, and Requires-Python, we can cheat a bit here.
|
72 |
-
name, open_bracket, _ = identifier.partition("[")
|
73 |
-
if open_bracket and name in mapping:
|
74 |
-
return mapping[name]
|
75 |
-
return default
|
76 |
-
|
77 |
-
|
78 |
-
class PipProvider(_ProviderBase):
|
79 |
-
"""Pip's provider implementation for resolvelib.
|
80 |
-
|
81 |
-
:params constraints: A mapping of constraints specified by the user. Keys
|
82 |
-
are canonicalized project names.
|
83 |
-
:params ignore_dependencies: Whether the user specified ``--no-deps``.
|
84 |
-
:params upgrade_strategy: The user-specified upgrade strategy.
|
85 |
-
:params user_requested: A set of canonicalized package names that the user
|
86 |
-
supplied for pip to install/upgrade.
|
87 |
-
"""
|
88 |
-
|
89 |
-
def __init__(
|
90 |
-
self,
|
91 |
-
factory: Factory,
|
92 |
-
constraints: Dict[str, Constraint],
|
93 |
-
ignore_dependencies: bool,
|
94 |
-
upgrade_strategy: str,
|
95 |
-
user_requested: Dict[str, int],
|
96 |
-
) -> None:
|
97 |
-
self._factory = factory
|
98 |
-
self._constraints = constraints
|
99 |
-
self._ignore_dependencies = ignore_dependencies
|
100 |
-
self._upgrade_strategy = upgrade_strategy
|
101 |
-
self._user_requested = user_requested
|
102 |
-
self._known_depths: Dict[str, float] = collections.defaultdict(lambda: math.inf)
|
103 |
-
|
104 |
-
def identify(self, requirement_or_candidate: Union[Requirement, Candidate]) -> str:
|
105 |
-
return requirement_or_candidate.name
|
106 |
-
|
107 |
-
def get_preference(
|
108 |
-
self,
|
109 |
-
identifier: str,
|
110 |
-
resolutions: Mapping[str, Candidate],
|
111 |
-
candidates: Mapping[str, Iterator[Candidate]],
|
112 |
-
information: Mapping[str, Iterable["PreferenceInformation"]],
|
113 |
-
backtrack_causes: Sequence["PreferenceInformation"],
|
114 |
-
) -> "Preference":
|
115 |
-
"""Produce a sort key for given requirement based on preference.
|
116 |
-
|
117 |
-
The lower the return value is, the more preferred this group of
|
118 |
-
arguments is.
|
119 |
-
|
120 |
-
Currently pip considers the following in order:
|
121 |
-
|
122 |
-
* Prefer if any of the known requirements is "direct", e.g. points to an
|
123 |
-
explicit URL.
|
124 |
-
* If equal, prefer if any requirement is "pinned", i.e. contains
|
125 |
-
operator ``===`` or ``==``.
|
126 |
-
* If equal, calculate an approximate "depth" and resolve requirements
|
127 |
-
closer to the user-specified requirements first. If the depth cannot
|
128 |
-
by determined (eg: due to no matching parents), it is considered
|
129 |
-
infinite.
|
130 |
-
* Order user-specified requirements by the order they are specified.
|
131 |
-
* If equal, prefers "non-free" requirements, i.e. contains at least one
|
132 |
-
operator, such as ``>=`` or ``<``.
|
133 |
-
* If equal, order alphabetically for consistency (helps debuggability).
|
134 |
-
"""
|
135 |
-
try:
|
136 |
-
next(iter(information[identifier]))
|
137 |
-
except StopIteration:
|
138 |
-
# There is no information for this identifier, so there's no known
|
139 |
-
# candidates.
|
140 |
-
has_information = False
|
141 |
-
else:
|
142 |
-
has_information = True
|
143 |
-
|
144 |
-
if has_information:
|
145 |
-
lookups = (r.get_candidate_lookup() for r, _ in information[identifier])
|
146 |
-
candidate, ireqs = zip(*lookups)
|
147 |
-
else:
|
148 |
-
candidate, ireqs = None, ()
|
149 |
-
|
150 |
-
operators = [
|
151 |
-
specifier.operator
|
152 |
-
for specifier_set in (ireq.specifier for ireq in ireqs if ireq)
|
153 |
-
for specifier in specifier_set
|
154 |
-
]
|
155 |
-
|
156 |
-
direct = candidate is not None
|
157 |
-
pinned = any(op[:2] == "==" for op in operators)
|
158 |
-
unfree = bool(operators)
|
159 |
-
|
160 |
-
try:
|
161 |
-
requested_order: Union[int, float] = self._user_requested[identifier]
|
162 |
-
except KeyError:
|
163 |
-
requested_order = math.inf
|
164 |
-
if has_information:
|
165 |
-
parent_depths = (
|
166 |
-
self._known_depths[parent.name] if parent is not None else 0.0
|
167 |
-
for _, parent in information[identifier]
|
168 |
-
)
|
169 |
-
inferred_depth = min(d for d in parent_depths) + 1.0
|
170 |
-
else:
|
171 |
-
inferred_depth = math.inf
|
172 |
-
else:
|
173 |
-
inferred_depth = 1.0
|
174 |
-
self._known_depths[identifier] = inferred_depth
|
175 |
-
|
176 |
-
requested_order = self._user_requested.get(identifier, math.inf)
|
177 |
-
|
178 |
-
# Requires-Python has only one candidate and the check is basically
|
179 |
-
# free, so we always do it first to avoid needless work if it fails.
|
180 |
-
requires_python = identifier == REQUIRES_PYTHON_IDENTIFIER
|
181 |
-
|
182 |
-
# Prefer the causes of backtracking on the assumption that the problem
|
183 |
-
# resolving the dependency tree is related to the failures that caused
|
184 |
-
# the backtracking
|
185 |
-
backtrack_cause = self.is_backtrack_cause(identifier, backtrack_causes)
|
186 |
-
|
187 |
-
return (
|
188 |
-
not requires_python,
|
189 |
-
not direct,
|
190 |
-
not pinned,
|
191 |
-
not backtrack_cause,
|
192 |
-
inferred_depth,
|
193 |
-
requested_order,
|
194 |
-
not unfree,
|
195 |
-
identifier,
|
196 |
-
)
|
197 |
-
|
198 |
-
def find_matches(
|
199 |
-
self,
|
200 |
-
identifier: str,
|
201 |
-
requirements: Mapping[str, Iterator[Requirement]],
|
202 |
-
incompatibilities: Mapping[str, Iterator[Candidate]],
|
203 |
-
) -> Iterable[Candidate]:
|
204 |
-
def _eligible_for_upgrade(identifier: str) -> bool:
|
205 |
-
"""Are upgrades allowed for this project?
|
206 |
-
|
207 |
-
This checks the upgrade strategy, and whether the project was one
|
208 |
-
that the user specified in the command line, in order to decide
|
209 |
-
whether we should upgrade if there's a newer version available.
|
210 |
-
|
211 |
-
(Note that we don't need access to the `--upgrade` flag, because
|
212 |
-
an upgrade strategy of "to-satisfy-only" means that `--upgrade`
|
213 |
-
was not specified).
|
214 |
-
"""
|
215 |
-
if self._upgrade_strategy == "eager":
|
216 |
-
return True
|
217 |
-
elif self._upgrade_strategy == "only-if-needed":
|
218 |
-
user_order = _get_with_identifier(
|
219 |
-
self._user_requested,
|
220 |
-
identifier,
|
221 |
-
default=None,
|
222 |
-
)
|
223 |
-
return user_order is not None
|
224 |
-
return False
|
225 |
-
|
226 |
-
constraint = _get_with_identifier(
|
227 |
-
self._constraints,
|
228 |
-
identifier,
|
229 |
-
default=Constraint.empty(),
|
230 |
-
)
|
231 |
-
return self._factory.find_candidates(
|
232 |
-
identifier=identifier,
|
233 |
-
requirements=requirements,
|
234 |
-
constraint=constraint,
|
235 |
-
prefers_installed=(not _eligible_for_upgrade(identifier)),
|
236 |
-
incompatibilities=incompatibilities,
|
237 |
-
)
|
238 |
-
|
239 |
-
def is_satisfied_by(self, requirement: Requirement, candidate: Candidate) -> bool:
|
240 |
-
return requirement.is_satisfied_by(candidate)
|
241 |
-
|
242 |
-
def get_dependencies(self, candidate: Candidate) -> Sequence[Requirement]:
|
243 |
-
with_requires = not self._ignore_dependencies
|
244 |
-
return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
|
245 |
-
|
246 |
-
@staticmethod
|
247 |
-
def is_backtrack_cause(
|
248 |
-
identifier: str, backtrack_causes: Sequence["PreferenceInformation"]
|
249 |
-
) -> bool:
|
250 |
-
for backtrack_cause in backtrack_causes:
|
251 |
-
if identifier == backtrack_cause.requirement.name:
|
252 |
-
return True
|
253 |
-
if backtrack_cause.parent and identifier == backtrack_cause.parent.name:
|
254 |
-
return True
|
255 |
-
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/rich/styled.py
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
from typing import TYPE_CHECKING
|
2 |
-
|
3 |
-
from .measure import Measurement
|
4 |
-
from .segment import Segment
|
5 |
-
from .style import StyleType
|
6 |
-
|
7 |
-
if TYPE_CHECKING:
|
8 |
-
from .console import Console, ConsoleOptions, RenderResult, RenderableType
|
9 |
-
|
10 |
-
|
11 |
-
class Styled:
|
12 |
-
"""Apply a style to a renderable.
|
13 |
-
|
14 |
-
Args:
|
15 |
-
renderable (RenderableType): Any renderable.
|
16 |
-
style (StyleType): A style to apply across the entire renderable.
|
17 |
-
"""
|
18 |
-
|
19 |
-
def __init__(self, renderable: "RenderableType", style: "StyleType") -> None:
|
20 |
-
self.renderable = renderable
|
21 |
-
self.style = style
|
22 |
-
|
23 |
-
def __rich_console__(
|
24 |
-
self, console: "Console", options: "ConsoleOptions"
|
25 |
-
) -> "RenderResult":
|
26 |
-
style = console.get_style(self.style)
|
27 |
-
rendered_segments = console.render(self.renderable, options)
|
28 |
-
segments = Segment.apply_style(rendered_segments, style)
|
29 |
-
return segments
|
30 |
-
|
31 |
-
def __rich_measure__(
|
32 |
-
self, console: "Console", options: "ConsoleOptions"
|
33 |
-
) -> Measurement:
|
34 |
-
return Measurement.get(console, options, self.renderable)
|
35 |
-
|
36 |
-
|
37 |
-
if __name__ == "__main__": # pragma: no cover
|
38 |
-
from pip._vendor.rich import print
|
39 |
-
from pip._vendor.rich.panel import Panel
|
40 |
-
|
41 |
-
panel = Styled(Panel("hello"), "on blue")
|
42 |
-
print(panel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/pip/_vendor/urllib3/connectionpool.py
DELETED
@@ -1,1110 +0,0 @@
|
|
1 |
-
from __future__ import absolute_import
|
2 |
-
|
3 |
-
import errno
|
4 |
-
import logging
|
5 |
-
import re
|
6 |
-
import socket
|
7 |
-
import sys
|
8 |
-
import warnings
|
9 |
-
from socket import error as SocketError
|
10 |
-
from socket import timeout as SocketTimeout
|
11 |
-
|
12 |
-
from .connection import (
|
13 |
-
BaseSSLError,
|
14 |
-
BrokenPipeError,
|
15 |
-
DummyConnection,
|
16 |
-
HTTPConnection,
|
17 |
-
HTTPException,
|
18 |
-
HTTPSConnection,
|
19 |
-
VerifiedHTTPSConnection,
|
20 |
-
port_by_scheme,
|
21 |
-
)
|
22 |
-
from .exceptions import (
|
23 |
-
ClosedPoolError,
|
24 |
-
EmptyPoolError,
|
25 |
-
HeaderParsingError,
|
26 |
-
HostChangedError,
|
27 |
-
InsecureRequestWarning,
|
28 |
-
LocationValueError,
|
29 |
-
MaxRetryError,
|
30 |
-
NewConnectionError,
|
31 |
-
ProtocolError,
|
32 |
-
ProxyError,
|
33 |
-
ReadTimeoutError,
|
34 |
-
SSLError,
|
35 |
-
TimeoutError,
|
36 |
-
)
|
37 |
-
from .packages import six
|
38 |
-
from .packages.six.moves import queue
|
39 |
-
from .request import RequestMethods
|
40 |
-
from .response import HTTPResponse
|
41 |
-
from .util.connection import is_connection_dropped
|
42 |
-
from .util.proxy import connection_requires_http_tunnel
|
43 |
-
from .util.queue import LifoQueue
|
44 |
-
from .util.request import set_file_position
|
45 |
-
from .util.response import assert_header_parsing
|
46 |
-
from .util.retry import Retry
|
47 |
-
from .util.ssl_match_hostname import CertificateError
|
48 |
-
from .util.timeout import Timeout
|
49 |
-
from .util.url import Url, _encode_target
|
50 |
-
from .util.url import _normalize_host as normalize_host
|
51 |
-
from .util.url import get_host, parse_url
|
52 |
-
|
53 |
-
xrange = six.moves.xrange
|
54 |
-
|
55 |
-
log = logging.getLogger(__name__)
|
56 |
-
|
57 |
-
_Default = object()
|
58 |
-
|
59 |
-
|
60 |
-
# Pool objects
|
61 |
-
class ConnectionPool(object):
|
62 |
-
"""
|
63 |
-
Base class for all connection pools, such as
|
64 |
-
:class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`.
|
65 |
-
|
66 |
-
.. note::
|
67 |
-
ConnectionPool.urlopen() does not normalize or percent-encode target URIs
|
68 |
-
which is useful if your target server doesn't support percent-encoded
|
69 |
-
target URIs.
|
70 |
-
"""
|
71 |
-
|
72 |
-
scheme = None
|
73 |
-
QueueCls = LifoQueue
|
74 |
-
|
75 |
-
def __init__(self, host, port=None):
|
76 |
-
if not host:
|
77 |
-
raise LocationValueError("No host specified.")
|
78 |
-
|
79 |
-
self.host = _normalize_host(host, scheme=self.scheme)
|
80 |
-
self._proxy_host = host.lower()
|
81 |
-
self.port = port
|
82 |
-
|
83 |
-
def __str__(self):
|
84 |
-
return "%s(host=%r, port=%r)" % (type(self).__name__, self.host, self.port)
|
85 |
-
|
86 |
-
def __enter__(self):
|
87 |
-
return self
|
88 |
-
|
89 |
-
def __exit__(self, exc_type, exc_val, exc_tb):
|
90 |
-
self.close()
|
91 |
-
# Return False to re-raise any potential exceptions
|
92 |
-
return False
|
93 |
-
|
94 |
-
def close(self):
|
95 |
-
"""
|
96 |
-
Close all pooled connections and disable the pool.
|
97 |
-
"""
|
98 |
-
pass
|
99 |
-
|
100 |
-
|
101 |
-
# This is taken from http://hg.python.org/cpython/file/7aaba721ebc0/Lib/socket.py#l252
|
102 |
-
_blocking_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}
|
103 |
-
|
104 |
-
|
105 |
-
class HTTPConnectionPool(ConnectionPool, RequestMethods):
|
106 |
-
"""
|
107 |
-
Thread-safe connection pool for one host.
|
108 |
-
|
109 |
-
:param host:
|
110 |
-
Host used for this HTTP Connection (e.g. "localhost"), passed into
|
111 |
-
:class:`http.client.HTTPConnection`.
|
112 |
-
|
113 |
-
:param port:
|
114 |
-
Port used for this HTTP Connection (None is equivalent to 80), passed
|
115 |
-
into :class:`http.client.HTTPConnection`.
|
116 |
-
|
117 |
-
:param strict:
|
118 |
-
Causes BadStatusLine to be raised if the status line can't be parsed
|
119 |
-
as a valid HTTP/1.0 or 1.1 status line, passed into
|
120 |
-
:class:`http.client.HTTPConnection`.
|
121 |
-
|
122 |
-
.. note::
|
123 |
-
Only works in Python 2. This parameter is ignored in Python 3.
|
124 |
-
|
125 |
-
:param timeout:
|
126 |
-
Socket timeout in seconds for each individual connection. This can
|
127 |
-
be a float or integer, which sets the timeout for the HTTP request,
|
128 |
-
or an instance of :class:`urllib3.util.Timeout` which gives you more
|
129 |
-
fine-grained control over request timeouts. After the constructor has
|
130 |
-
been parsed, this is always a `urllib3.util.Timeout` object.
|
131 |
-
|
132 |
-
:param maxsize:
|
133 |
-
Number of connections to save that can be reused. More than 1 is useful
|
134 |
-
in multithreaded situations. If ``block`` is set to False, more
|
135 |
-
connections will be created but they will not be saved once they've
|
136 |
-
been used.
|
137 |
-
|
138 |
-
:param block:
|
139 |
-
If set to True, no more than ``maxsize`` connections will be used at
|
140 |
-
a time. When no free connections are available, the call will block
|
141 |
-
until a connection has been released. This is a useful side effect for
|
142 |
-
particular multithreaded situations where one does not want to use more
|
143 |
-
than maxsize connections per host to prevent flooding.
|
144 |
-
|
145 |
-
:param headers:
|
146 |
-
Headers to include with all requests, unless other headers are given
|
147 |
-
explicitly.
|
148 |
-
|
149 |
-
:param retries:
|
150 |
-
Retry configuration to use by default with requests in this pool.
|
151 |
-
|
152 |
-
:param _proxy:
|
153 |
-
Parsed proxy URL, should not be used directly, instead, see
|
154 |
-
:class:`urllib3.ProxyManager`
|
155 |
-
|
156 |
-
:param _proxy_headers:
|
157 |
-
A dictionary with proxy headers, should not be used directly,
|
158 |
-
instead, see :class:`urllib3.ProxyManager`
|
159 |
-
|
160 |
-
:param \\**conn_kw:
|
161 |
-
Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`,
|
162 |
-
:class:`urllib3.connection.HTTPSConnection` instances.
|
163 |
-
"""
|
164 |
-
|
165 |
-
scheme = "http"
|
166 |
-
ConnectionCls = HTTPConnection
|
167 |
-
ResponseCls = HTTPResponse
|
168 |
-
|
169 |
-
def __init__(
|
170 |
-
self,
|
171 |
-
host,
|
172 |
-
port=None,
|
173 |
-
strict=False,
|
174 |
-
timeout=Timeout.DEFAULT_TIMEOUT,
|
175 |
-
maxsize=1,
|
176 |
-
block=False,
|
177 |
-
headers=None,
|
178 |
-
retries=None,
|
179 |
-
_proxy=None,
|
180 |
-
_proxy_headers=None,
|
181 |
-
_proxy_config=None,
|
182 |
-
**conn_kw
|
183 |
-
):
|
184 |
-
ConnectionPool.__init__(self, host, port)
|
185 |
-
RequestMethods.__init__(self, headers)
|
186 |
-
|
187 |
-
self.strict = strict
|
188 |
-
|
189 |
-
if not isinstance(timeout, Timeout):
|
190 |
-
timeout = Timeout.from_float(timeout)
|
191 |
-
|
192 |
-
if retries is None:
|
193 |
-
retries = Retry.DEFAULT
|
194 |
-
|
195 |
-
self.timeout = timeout
|
196 |
-
self.retries = retries
|
197 |
-
|
198 |
-
self.pool = self.QueueCls(maxsize)
|
199 |
-
self.block = block
|
200 |
-
|
201 |
-
self.proxy = _proxy
|
202 |
-
self.proxy_headers = _proxy_headers or {}
|
203 |
-
self.proxy_config = _proxy_config
|
204 |
-
|
205 |
-
# Fill the queue up so that doing get() on it will block properly
|
206 |
-
for _ in xrange(maxsize):
|
207 |
-
self.pool.put(None)
|
208 |
-
|
209 |
-
# These are mostly for testing and debugging purposes.
|
210 |
-
self.num_connections = 0
|
211 |
-
self.num_requests = 0
|
212 |
-
self.conn_kw = conn_kw
|
213 |
-
|
214 |
-
if self.proxy:
|
215 |
-
# Enable Nagle's algorithm for proxies, to avoid packet fragmentation.
|
216 |
-
# We cannot know if the user has added default socket options, so we cannot replace the
|
217 |
-
# list.
|
218 |
-
self.conn_kw.setdefault("socket_options", [])
|
219 |
-
|
220 |
-
self.conn_kw["proxy"] = self.proxy
|
221 |
-
self.conn_kw["proxy_config"] = self.proxy_config
|
222 |
-
|
223 |
-
def _new_conn(self):
|
224 |
-
"""
|
225 |
-
Return a fresh :class:`HTTPConnection`.
|
226 |
-
"""
|
227 |
-
self.num_connections += 1
|
228 |
-
log.debug(
|
229 |
-
"Starting new HTTP connection (%d): %s:%s",
|
230 |
-
self.num_connections,
|
231 |
-
self.host,
|
232 |
-
self.port or "80",
|
233 |
-
)
|
234 |
-
|
235 |
-
conn = self.ConnectionCls(
|
236 |
-
host=self.host,
|
237 |
-
port=self.port,
|
238 |
-
timeout=self.timeout.connect_timeout,
|
239 |
-
strict=self.strict,
|
240 |
-
**self.conn_kw
|
241 |
-
)
|
242 |
-
return conn
|
243 |
-
|
244 |
-
def _get_conn(self, timeout=None):
|
245 |
-
"""
|
246 |
-
Get a connection. Will return a pooled connection if one is available.
|
247 |
-
|
248 |
-
If no connections are available and :prop:`.block` is ``False``, then a
|
249 |
-
fresh connection is returned.
|
250 |
-
|
251 |
-
:param timeout:
|
252 |
-
Seconds to wait before giving up and raising
|
253 |
-
:class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and
|
254 |
-
:prop:`.block` is ``True``.
|
255 |
-
"""
|
256 |
-
conn = None
|
257 |
-
try:
|
258 |
-
conn = self.pool.get(block=self.block, timeout=timeout)
|
259 |
-
|
260 |
-
except AttributeError: # self.pool is None
|
261 |
-
raise ClosedPoolError(self, "Pool is closed.")
|
262 |
-
|
263 |
-
except queue.Empty:
|
264 |
-
if self.block:
|
265 |
-
raise EmptyPoolError(
|
266 |
-
self,
|
267 |
-
"Pool reached maximum size and no more connections are allowed.",
|
268 |
-
)
|
269 |
-
pass # Oh well, we'll create a new connection then
|
270 |
-
|
271 |
-
# If this is a persistent connection, check if it got disconnected
|
272 |
-
if conn and is_connection_dropped(conn):
|
273 |
-
log.debug("Resetting dropped connection: %s", self.host)
|
274 |
-
conn.close()
|
275 |
-
if getattr(conn, "auto_open", 1) == 0:
|
276 |
-
# This is a proxied connection that has been mutated by
|
277 |
-
# http.client._tunnel() and cannot be reused (since it would
|
278 |
-
# attempt to bypass the proxy)
|
279 |
-
conn = None
|
280 |
-
|
281 |
-
return conn or self._new_conn()
|
282 |
-
|
283 |
-
def _put_conn(self, conn):
|
284 |
-
"""
|
285 |
-
Put a connection back into the pool.
|
286 |
-
|
287 |
-
:param conn:
|
288 |
-
Connection object for the current host and port as returned by
|
289 |
-
:meth:`._new_conn` or :meth:`._get_conn`.
|
290 |
-
|
291 |
-
If the pool is already full, the connection is closed and discarded
|
292 |
-
because we exceeded maxsize. If connections are discarded frequently,
|
293 |
-
then maxsize should be increased.
|
294 |
-
|
295 |
-
If the pool is closed, then the connection will be closed and discarded.
|
296 |
-
"""
|
297 |
-
try:
|
298 |
-
self.pool.put(conn, block=False)
|
299 |
-
return # Everything is dandy, done.
|
300 |
-
except AttributeError:
|
301 |
-
# self.pool is None.
|
302 |
-
pass
|
303 |
-
except queue.Full:
|
304 |
-
# This should never happen if self.block == True
|
305 |
-
log.warning(
|
306 |
-
"Connection pool is full, discarding connection: %s. Connection pool size: %s",
|
307 |
-
self.host,
|
308 |
-
self.pool.qsize(),
|
309 |
-
)
|
310 |
-
# Connection never got put back into the pool, close it.
|
311 |
-
if conn:
|
312 |
-
conn.close()
|
313 |
-
|
314 |
-
def _validate_conn(self, conn):
|
315 |
-
"""
|
316 |
-
Called right before a request is made, after the socket is created.
|
317 |
-
"""
|
318 |
-
pass
|
319 |
-
|
320 |
-
def _prepare_proxy(self, conn):
|
321 |
-
# Nothing to do for HTTP connections.
|
322 |
-
pass
|
323 |
-
|
324 |
-
def _get_timeout(self, timeout):
|
325 |
-
"""Helper that always returns a :class:`urllib3.util.Timeout`"""
|
326 |
-
if timeout is _Default:
|
327 |
-
return self.timeout.clone()
|
328 |
-
|
329 |
-
if isinstance(timeout, Timeout):
|
330 |
-
return timeout.clone()
|
331 |
-
else:
|
332 |
-
# User passed us an int/float. This is for backwards compatibility,
|
333 |
-
# can be removed later
|
334 |
-
return Timeout.from_float(timeout)
|
335 |
-
|
336 |
-
def _raise_timeout(self, err, url, timeout_value):
|
337 |
-
"""Is the error actually a timeout? Will raise a ReadTimeout or pass"""
|
338 |
-
|
339 |
-
if isinstance(err, SocketTimeout):
|
340 |
-
raise ReadTimeoutError(
|
341 |
-
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
342 |
-
)
|
343 |
-
|
344 |
-
# See the above comment about EAGAIN in Python 3. In Python 2 we have
|
345 |
-
# to specifically catch it and throw the timeout error
|
346 |
-
if hasattr(err, "errno") and err.errno in _blocking_errnos:
|
347 |
-
raise ReadTimeoutError(
|
348 |
-
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
349 |
-
)
|
350 |
-
|
351 |
-
# Catch possible read timeouts thrown as SSL errors. If not the
|
352 |
-
# case, rethrow the original. We need to do this because of:
|
353 |
-
# http://bugs.python.org/issue10272
|
354 |
-
if "timed out" in str(err) or "did not complete (read)" in str(
|
355 |
-
err
|
356 |
-
): # Python < 2.7.4
|
357 |
-
raise ReadTimeoutError(
|
358 |
-
self, url, "Read timed out. (read timeout=%s)" % timeout_value
|
359 |
-
)
|
360 |
-
|
361 |
-
def _make_request(
|
362 |
-
self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw
|
363 |
-
):
|
364 |
-
"""
|
365 |
-
Perform a request on a given urllib connection object taken from our
|
366 |
-
pool.
|
367 |
-
|
368 |
-
:param conn:
|
369 |
-
a connection from one of our connection pools
|
370 |
-
|
371 |
-
:param timeout:
|
372 |
-
Socket timeout in seconds for the request. This can be a
|
373 |
-
float or integer, which will set the same timeout value for
|
374 |
-
the socket connect and the socket read, or an instance of
|
375 |
-
:class:`urllib3.util.Timeout`, which gives you more fine-grained
|
376 |
-
control over your timeouts.
|
377 |
-
"""
|
378 |
-
self.num_requests += 1
|
379 |
-
|
380 |
-
timeout_obj = self._get_timeout(timeout)
|
381 |
-
timeout_obj.start_connect()
|
382 |
-
conn.timeout = Timeout.resolve_default_timeout(timeout_obj.connect_timeout)
|
383 |
-
|
384 |
-
# Trigger any extra validation we need to do.
|
385 |
-
try:
|
386 |
-
self._validate_conn(conn)
|
387 |
-
except (SocketTimeout, BaseSSLError) as e:
|
388 |
-
# Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout.
|
389 |
-
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
|
390 |
-
raise
|
391 |
-
|
392 |
-
# conn.request() calls http.client.*.request, not the method in
|
393 |
-
# urllib3.request. It also calls makefile (recv) on the socket.
|
394 |
-
try:
|
395 |
-
if chunked:
|
396 |
-
conn.request_chunked(method, url, **httplib_request_kw)
|
397 |
-
else:
|
398 |
-
conn.request(method, url, **httplib_request_kw)
|
399 |
-
|
400 |
-
# We are swallowing BrokenPipeError (errno.EPIPE) since the server is
|
401 |
-
# legitimately able to close the connection after sending a valid response.
|
402 |
-
# With this behaviour, the received response is still readable.
|
403 |
-
except BrokenPipeError:
|
404 |
-
# Python 3
|
405 |
-
pass
|
406 |
-
except IOError as e:
|
407 |
-
# Python 2 and macOS/Linux
|
408 |
-
# EPIPE and ESHUTDOWN are BrokenPipeError on Python 2, and EPROTOTYPE is needed on macOS
|
409 |
-
# https://erickt.github.io/blog/2014/11/19/adventures-in-debugging-a-potential-osx-kernel-bug/
|
410 |
-
if e.errno not in {
|
411 |
-
errno.EPIPE,
|
412 |
-
errno.ESHUTDOWN,
|
413 |
-
errno.EPROTOTYPE,
|
414 |
-
}:
|
415 |
-
raise
|
416 |
-
|
417 |
-
# Reset the timeout for the recv() on the socket
|
418 |
-
read_timeout = timeout_obj.read_timeout
|
419 |
-
|
420 |
-
# App Engine doesn't have a sock attr
|
421 |
-
if getattr(conn, "sock", None):
|
422 |
-
# In Python 3 socket.py will catch EAGAIN and return None when you
|
423 |
-
# try and read into the file pointer created by http.client, which
|
424 |
-
# instead raises a BadStatusLine exception. Instead of catching
|
425 |
-
# the exception and assuming all BadStatusLine exceptions are read
|
426 |
-
# timeouts, check for a zero timeout before making the request.
|
427 |
-
if read_timeout == 0:
|
428 |
-
raise ReadTimeoutError(
|
429 |
-
self, url, "Read timed out. (read timeout=%s)" % read_timeout
|
430 |
-
)
|
431 |
-
if read_timeout is Timeout.DEFAULT_TIMEOUT:
|
432 |
-
conn.sock.settimeout(socket.getdefaulttimeout())
|
433 |
-
else: # None or a value
|
434 |
-
conn.sock.settimeout(read_timeout)
|
435 |
-
|
436 |
-
# Receive the response from the server
|
437 |
-
try:
|
438 |
-
try:
|
439 |
-
# Python 2.7, use buffering of HTTP responses
|
440 |
-
httplib_response = conn.getresponse(buffering=True)
|
441 |
-
except TypeError:
|
442 |
-
# Python 3
|
443 |
-
try:
|
444 |
-
httplib_response = conn.getresponse()
|
445 |
-
except BaseException as e:
|
446 |
-
# Remove the TypeError from the exception chain in
|
447 |
-
# Python 3 (including for exceptions like SystemExit).
|
448 |
-
# Otherwise it looks like a bug in the code.
|
449 |
-
six.raise_from(e, None)
|
450 |
-
except (SocketTimeout, BaseSSLError, SocketError) as e:
|
451 |
-
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
|
452 |
-
raise
|
453 |
-
|
454 |
-
# AppEngine doesn't have a version attr.
|
455 |
-
http_version = getattr(conn, "_http_vsn_str", "HTTP/?")
|
456 |
-
log.debug(
|
457 |
-
'%s://%s:%s "%s %s %s" %s %s',
|
458 |
-
self.scheme,
|
459 |
-
self.host,
|
460 |
-
self.port,
|
461 |
-
method,
|
462 |
-
url,
|
463 |
-
http_version,
|
464 |
-
httplib_response.status,
|
465 |
-
httplib_response.length,
|
466 |
-
)
|
467 |
-
|
468 |
-
try:
|
469 |
-
assert_header_parsing(httplib_response.msg)
|
470 |
-
except (HeaderParsingError, TypeError) as hpe: # Platform-specific: Python 3
|
471 |
-
log.warning(
|
472 |
-
"Failed to parse headers (url=%s): %s",
|
473 |
-
self._absolute_url(url),
|
474 |
-
hpe,
|
475 |
-
exc_info=True,
|
476 |
-
)
|
477 |
-
|
478 |
-
return httplib_response
|
479 |
-
|
480 |
-
def _absolute_url(self, path):
|
481 |
-
return Url(scheme=self.scheme, host=self.host, port=self.port, path=path).url
|
482 |
-
|
483 |
-
def close(self):
|
484 |
-
"""
|
485 |
-
Close all pooled connections and disable the pool.
|
486 |
-
"""
|
487 |
-
if self.pool is None:
|
488 |
-
return
|
489 |
-
# Disable access to the pool
|
490 |
-
old_pool, self.pool = self.pool, None
|
491 |
-
|
492 |
-
try:
|
493 |
-
while True:
|
494 |
-
conn = old_pool.get(block=False)
|
495 |
-
if conn:
|
496 |
-
conn.close()
|
497 |
-
|
498 |
-
except queue.Empty:
|
499 |
-
pass # Done.
|
500 |
-
|
501 |
-
def is_same_host(self, url):
|
502 |
-
"""
|
503 |
-
Check if the given ``url`` is a member of the same host as this
|
504 |
-
connection pool.
|
505 |
-
"""
|
506 |
-
if url.startswith("/"):
|
507 |
-
return True
|
508 |
-
|
509 |
-
# TODO: Add optional support for socket.gethostbyname checking.
|
510 |
-
scheme, host, port = get_host(url)
|
511 |
-
if host is not None:
|
512 |
-
host = _normalize_host(host, scheme=scheme)
|
513 |
-
|
514 |
-
# Use explicit default port for comparison when none is given
|
515 |
-
if self.port and not port:
|
516 |
-
port = port_by_scheme.get(scheme)
|
517 |
-
elif not self.port and port == port_by_scheme.get(scheme):
|
518 |
-
port = None
|
519 |
-
|
520 |
-
return (scheme, host, port) == (self.scheme, self.host, self.port)
|
521 |
-
|
522 |
-
def urlopen(
|
523 |
-
self,
|
524 |
-
method,
|
525 |
-
url,
|
526 |
-
body=None,
|
527 |
-
headers=None,
|
528 |
-
retries=None,
|
529 |
-
redirect=True,
|
530 |
-
assert_same_host=True,
|
531 |
-
timeout=_Default,
|
532 |
-
pool_timeout=None,
|
533 |
-
release_conn=None,
|
534 |
-
chunked=False,
|
535 |
-
body_pos=None,
|
536 |
-
**response_kw
|
537 |
-
):
|
538 |
-
"""
|
539 |
-
Get a connection from the pool and perform an HTTP request. This is the
|
540 |
-
lowest level call for making a request, so you'll need to specify all
|
541 |
-
the raw details.
|
542 |
-
|
543 |
-
.. note::
|
544 |
-
|
545 |
-
More commonly, it's appropriate to use a convenience method provided
|
546 |
-
by :class:`.RequestMethods`, such as :meth:`request`.
|
547 |
-
|
548 |
-
.. note::
|
549 |
-
|
550 |
-
`release_conn` will only behave as expected if
|
551 |
-
`preload_content=False` because we want to make
|
552 |
-
`preload_content=False` the default behaviour someday soon without
|
553 |
-
breaking backwards compatibility.
|
554 |
-
|
555 |
-
:param method:
|
556 |
-
HTTP request method (such as GET, POST, PUT, etc.)
|
557 |
-
|
558 |
-
:param url:
|
559 |
-
The URL to perform the request on.
|
560 |
-
|
561 |
-
:param body:
|
562 |
-
Data to send in the request body, either :class:`str`, :class:`bytes`,
|
563 |
-
an iterable of :class:`str`/:class:`bytes`, or a file-like object.
|
564 |
-
|
565 |
-
:param headers:
|
566 |
-
Dictionary of custom headers to send, such as User-Agent,
|
567 |
-
If-None-Match, etc. If None, pool headers are used. If provided,
|
568 |
-
these headers completely replace any pool-specific headers.
|
569 |
-
|
570 |
-
:param retries:
|
571 |
-
Configure the number of retries to allow before raising a
|
572 |
-
:class:`~urllib3.exceptions.MaxRetryError` exception.
|
573 |
-
|
574 |
-
Pass ``None`` to retry until you receive a response. Pass a
|
575 |
-
:class:`~urllib3.util.retry.Retry` object for fine-grained control
|
576 |
-
over different types of retries.
|
577 |
-
Pass an integer number to retry connection errors that many times,
|
578 |
-
but no other types of errors. Pass zero to never retry.
|
579 |
-
|
580 |
-
If ``False``, then retries are disabled and any exception is raised
|
581 |
-
immediately. Also, instead of raising a MaxRetryError on redirects,
|
582 |
-
the redirect response will be returned.
|
583 |
-
|
584 |
-
:type retries: :class:`~urllib3.util.retry.Retry`, False, or an int.
|
585 |
-
|
586 |
-
:param redirect:
|
587 |
-
If True, automatically handle redirects (status codes 301, 302,
|
588 |
-
303, 307, 308). Each redirect counts as a retry. Disabling retries
|
589 |
-
will disable redirect, too.
|
590 |
-
|
591 |
-
:param assert_same_host:
|
592 |
-
If ``True``, will make sure that the host of the pool requests is
|
593 |
-
consistent else will raise HostChangedError. When ``False``, you can
|
594 |
-
use the pool on an HTTP proxy and request foreign hosts.
|
595 |
-
|
596 |
-
:param timeout:
|
597 |
-
If specified, overrides the default timeout for this one
|
598 |
-
request. It may be a float (in seconds) or an instance of
|
599 |
-
:class:`urllib3.util.Timeout`.
|
600 |
-
|
601 |
-
:param pool_timeout:
|
602 |
-
If set and the pool is set to block=True, then this method will
|
603 |
-
block for ``pool_timeout`` seconds and raise EmptyPoolError if no
|
604 |
-
connection is available within the time period.
|
605 |
-
|
606 |
-
:param release_conn:
|
607 |
-
If False, then the urlopen call will not release the connection
|
608 |
-
back into the pool once a response is received (but will release if
|
609 |
-
you read the entire contents of the response such as when
|
610 |
-
`preload_content=True`). This is useful if you're not preloading
|
611 |
-
the response's content immediately. You will need to call
|
612 |
-
``r.release_conn()`` on the response ``r`` to return the connection
|
613 |
-
back into the pool. If None, it takes the value of
|
614 |
-
``response_kw.get('preload_content', True)``.
|
615 |
-
|
616 |
-
:param chunked:
|
617 |
-
If True, urllib3 will send the body using chunked transfer
|
618 |
-
encoding. Otherwise, urllib3 will send the body using the standard
|
619 |
-
content-length form. Defaults to False.
|
620 |
-
|
621 |
-
:param int body_pos:
|
622 |
-
Position to seek to in file-like body in the event of a retry or
|
623 |
-
redirect. Typically this won't need to be set because urllib3 will
|
624 |
-
auto-populate the value when needed.
|
625 |
-
|
626 |
-
:param \\**response_kw:
|
627 |
-
Additional parameters are passed to
|
628 |
-
:meth:`urllib3.response.HTTPResponse.from_httplib`
|
629 |
-
"""
|
630 |
-
|
631 |
-
parsed_url = parse_url(url)
|
632 |
-
destination_scheme = parsed_url.scheme
|
633 |
-
|
634 |
-
if headers is None:
|
635 |
-
headers = self.headers
|
636 |
-
|
637 |
-
if not isinstance(retries, Retry):
|
638 |
-
retries = Retry.from_int(retries, redirect=redirect, default=self.retries)
|
639 |
-
|
640 |
-
if release_conn is None:
|
641 |
-
release_conn = response_kw.get("preload_content", True)
|
642 |
-
|
643 |
-
# Check host
|
644 |
-
if assert_same_host and not self.is_same_host(url):
|
645 |
-
raise HostChangedError(self, url, retries)
|
646 |
-
|
647 |
-
# Ensure that the URL we're connecting to is properly encoded
|
648 |
-
if url.startswith("/"):
|
649 |
-
url = six.ensure_str(_encode_target(url))
|
650 |
-
else:
|
651 |
-
url = six.ensure_str(parsed_url.url)
|
652 |
-
|
653 |
-
conn = None
|
654 |
-
|
655 |
-
# Track whether `conn` needs to be released before
|
656 |
-
# returning/raising/recursing. Update this variable if necessary, and
|
657 |
-
# leave `release_conn` constant throughout the function. That way, if
|
658 |
-
# the function recurses, the original value of `release_conn` will be
|
659 |
-
# passed down into the recursive call, and its value will be respected.
|
660 |
-
#
|
661 |
-
# See issue #651 [1] for details.
|
662 |
-
#
|
663 |
-
# [1] <https://github.com/urllib3/urllib3/issues/651>
|
664 |
-
release_this_conn = release_conn
|
665 |
-
|
666 |
-
http_tunnel_required = connection_requires_http_tunnel(
|
667 |
-
self.proxy, self.proxy_config, destination_scheme
|
668 |
-
)
|
669 |
-
|
670 |
-
# Merge the proxy headers. Only done when not using HTTP CONNECT. We
|
671 |
-
# have to copy the headers dict so we can safely change it without those
|
672 |
-
# changes being reflected in anyone else's copy.
|
673 |
-
if not http_tunnel_required:
|
674 |
-
headers = headers.copy()
|
675 |
-
headers.update(self.proxy_headers)
|
676 |
-
|
677 |
-
# Must keep the exception bound to a separate variable or else Python 3
|
678 |
-
# complains about UnboundLocalError.
|
679 |
-
err = None
|
680 |
-
|
681 |
-
# Keep track of whether we cleanly exited the except block. This
|
682 |
-
# ensures we do proper cleanup in finally.
|
683 |
-
clean_exit = False
|
684 |
-
|
685 |
-
# Rewind body position, if needed. Record current position
|
686 |
-
# for future rewinds in the event of a redirect/retry.
|
687 |
-
body_pos = set_file_position(body, body_pos)
|
688 |
-
|
689 |
-
try:
|
690 |
-
# Request a connection from the queue.
|
691 |
-
timeout_obj = self._get_timeout(timeout)
|
692 |
-
conn = self._get_conn(timeout=pool_timeout)
|
693 |
-
|
694 |
-
conn.timeout = timeout_obj.connect_timeout
|
695 |
-
|
696 |
-
is_new_proxy_conn = self.proxy is not None and not getattr(
|
697 |
-
conn, "sock", None
|
698 |
-
)
|
699 |
-
if is_new_proxy_conn and http_tunnel_required:
|
700 |
-
self._prepare_proxy(conn)
|
701 |
-
|
702 |
-
# Make the request on the httplib connection object.
|
703 |
-
httplib_response = self._make_request(
|
704 |
-
conn,
|
705 |
-
method,
|
706 |
-
url,
|
707 |
-
timeout=timeout_obj,
|
708 |
-
body=body,
|
709 |
-
headers=headers,
|
710 |
-
chunked=chunked,
|
711 |
-
)
|
712 |
-
|
713 |
-
# If we're going to release the connection in ``finally:``, then
|
714 |
-
# the response doesn't need to know about the connection. Otherwise
|
715 |
-
# it will also try to release it and we'll have a double-release
|
716 |
-
# mess.
|
717 |
-
response_conn = conn if not release_conn else None
|
718 |
-
|
719 |
-
# Pass method to Response for length checking
|
720 |
-
response_kw["request_method"] = method
|
721 |
-
|
722 |
-
# Import httplib's response into our own wrapper object
|
723 |
-
response = self.ResponseCls.from_httplib(
|
724 |
-
httplib_response,
|
725 |
-
pool=self,
|
726 |
-
connection=response_conn,
|
727 |
-
retries=retries,
|
728 |
-
**response_kw
|
729 |
-
)
|
730 |
-
|
731 |
-
# Everything went great!
|
732 |
-
clean_exit = True
|
733 |
-
|
734 |
-
except EmptyPoolError:
|
735 |
-
# Didn't get a connection from the pool, no need to clean up
|
736 |
-
clean_exit = True
|
737 |
-
release_this_conn = False
|
738 |
-
raise
|
739 |
-
|
740 |
-
except (
|
741 |
-
TimeoutError,
|
742 |
-
HTTPException,
|
743 |
-
SocketError,
|
744 |
-
ProtocolError,
|
745 |
-
BaseSSLError,
|
746 |
-
SSLError,
|
747 |
-
CertificateError,
|
748 |
-
) as e:
|
749 |
-
# Discard the connection for these exceptions. It will be
|
750 |
-
# replaced during the next _get_conn() call.
|
751 |
-
clean_exit = False
|
752 |
-
|
753 |
-
def _is_ssl_error_message_from_http_proxy(ssl_error):
|
754 |
-
# We're trying to detect the message 'WRONG_VERSION_NUMBER' but
|
755 |
-
# SSLErrors are kinda all over the place when it comes to the message,
|
756 |
-
# so we try to cover our bases here!
|
757 |
-
message = " ".join(re.split("[^a-z]", str(ssl_error).lower()))
|
758 |
-
return (
|
759 |
-
"wrong version number" in message or "unknown protocol" in message
|
760 |
-
)
|
761 |
-
|
762 |
-
# Try to detect a common user error with proxies which is to
|
763 |
-
# set an HTTP proxy to be HTTPS when it should be 'http://'
|
764 |
-
# (ie {'http': 'http://proxy', 'https': 'https://proxy'})
|
765 |
-
# Instead we add a nice error message and point to a URL.
|
766 |
-
if (
|
767 |
-
isinstance(e, BaseSSLError)
|
768 |
-
and self.proxy
|
769 |
-
and _is_ssl_error_message_from_http_proxy(e)
|
770 |
-
and conn.proxy
|
771 |
-
and conn.proxy.scheme == "https"
|
772 |
-
):
|
773 |
-
e = ProxyError(
|
774 |
-
"Your proxy appears to only use HTTP and not HTTPS, "
|
775 |
-
"try changing your proxy URL to be HTTP. See: "
|
776 |
-
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
777 |
-
"#https-proxy-error-http-proxy",
|
778 |
-
SSLError(e),
|
779 |
-
)
|
780 |
-
elif isinstance(e, (BaseSSLError, CertificateError)):
|
781 |
-
e = SSLError(e)
|
782 |
-
elif isinstance(e, (SocketError, NewConnectionError)) and self.proxy:
|
783 |
-
e = ProxyError("Cannot connect to proxy.", e)
|
784 |
-
elif isinstance(e, (SocketError, HTTPException)):
|
785 |
-
e = ProtocolError("Connection aborted.", e)
|
786 |
-
|
787 |
-
retries = retries.increment(
|
788 |
-
method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
|
789 |
-
)
|
790 |
-
retries.sleep()
|
791 |
-
|
792 |
-
# Keep track of the error for the retry warning.
|
793 |
-
err = e
|
794 |
-
|
795 |
-
finally:
|
796 |
-
if not clean_exit:
|
797 |
-
# We hit some kind of exception, handled or otherwise. We need
|
798 |
-
# to throw the connection away unless explicitly told not to.
|
799 |
-
# Close the connection, set the variable to None, and make sure
|
800 |
-
# we put the None back in the pool to avoid leaking it.
|
801 |
-
conn = conn and conn.close()
|
802 |
-
release_this_conn = True
|
803 |
-
|
804 |
-
if release_this_conn:
|
805 |
-
# Put the connection back to be reused. If the connection is
|
806 |
-
# expired then it will be None, which will get replaced with a
|
807 |
-
# fresh connection during _get_conn.
|
808 |
-
self._put_conn(conn)
|
809 |
-
|
810 |
-
if not conn:
|
811 |
-
# Try again
|
812 |
-
log.warning(
|
813 |
-
"Retrying (%r) after connection broken by '%r': %s", retries, err, url
|
814 |
-
)
|
815 |
-
return self.urlopen(
|
816 |
-
method,
|
817 |
-
url,
|
818 |
-
body,
|
819 |
-
headers,
|
820 |
-
retries,
|
821 |
-
redirect,
|
822 |
-
assert_same_host,
|
823 |
-
timeout=timeout,
|
824 |
-
pool_timeout=pool_timeout,
|
825 |
-
release_conn=release_conn,
|
826 |
-
chunked=chunked,
|
827 |
-
body_pos=body_pos,
|
828 |
-
**response_kw
|
829 |
-
)
|
830 |
-
|
831 |
-
# Handle redirect?
|
832 |
-
redirect_location = redirect and response.get_redirect_location()
|
833 |
-
if redirect_location:
|
834 |
-
if response.status == 303:
|
835 |
-
method = "GET"
|
836 |
-
|
837 |
-
try:
|
838 |
-
retries = retries.increment(method, url, response=response, _pool=self)
|
839 |
-
except MaxRetryError:
|
840 |
-
if retries.raise_on_redirect:
|
841 |
-
response.drain_conn()
|
842 |
-
raise
|
843 |
-
return response
|
844 |
-
|
845 |
-
response.drain_conn()
|
846 |
-
retries.sleep_for_retry(response)
|
847 |
-
log.debug("Redirecting %s -> %s", url, redirect_location)
|
848 |
-
return self.urlopen(
|
849 |
-
method,
|
850 |
-
redirect_location,
|
851 |
-
body,
|
852 |
-
headers,
|
853 |
-
retries=retries,
|
854 |
-
redirect=redirect,
|
855 |
-
assert_same_host=assert_same_host,
|
856 |
-
timeout=timeout,
|
857 |
-
pool_timeout=pool_timeout,
|
858 |
-
release_conn=release_conn,
|
859 |
-
chunked=chunked,
|
860 |
-
body_pos=body_pos,
|
861 |
-
**response_kw
|
862 |
-
)
|
863 |
-
|
864 |
-
# Check if we should retry the HTTP response.
|
865 |
-
has_retry_after = bool(response.headers.get("Retry-After"))
|
866 |
-
if retries.is_retry(method, response.status, has_retry_after):
|
867 |
-
try:
|
868 |
-
retries = retries.increment(method, url, response=response, _pool=self)
|
869 |
-
except MaxRetryError:
|
870 |
-
if retries.raise_on_status:
|
871 |
-
response.drain_conn()
|
872 |
-
raise
|
873 |
-
return response
|
874 |
-
|
875 |
-
response.drain_conn()
|
876 |
-
retries.sleep(response)
|
877 |
-
log.debug("Retry: %s", url)
|
878 |
-
return self.urlopen(
|
879 |
-
method,
|
880 |
-
url,
|
881 |
-
body,
|
882 |
-
headers,
|
883 |
-
retries=retries,
|
884 |
-
redirect=redirect,
|
885 |
-
assert_same_host=assert_same_host,
|
886 |
-
timeout=timeout,
|
887 |
-
pool_timeout=pool_timeout,
|
888 |
-
release_conn=release_conn,
|
889 |
-
chunked=chunked,
|
890 |
-
body_pos=body_pos,
|
891 |
-
**response_kw
|
892 |
-
)
|
893 |
-
|
894 |
-
return response
|
895 |
-
|
896 |
-
|
897 |
-
class HTTPSConnectionPool(HTTPConnectionPool):
|
898 |
-
"""
|
899 |
-
Same as :class:`.HTTPConnectionPool`, but HTTPS.
|
900 |
-
|
901 |
-
:class:`.HTTPSConnection` uses one of ``assert_fingerprint``,
|
902 |
-
``assert_hostname`` and ``host`` in this order to verify connections.
|
903 |
-
If ``assert_hostname`` is False, no verification is done.
|
904 |
-
|
905 |
-
The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``,
|
906 |
-
``ca_cert_dir``, ``ssl_version``, ``key_password`` are only used if :mod:`ssl`
|
907 |
-
is available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade
|
908 |
-
the connection socket into an SSL socket.
|
909 |
-
"""
|
910 |
-
|
911 |
-
scheme = "https"
|
912 |
-
ConnectionCls = HTTPSConnection
|
913 |
-
|
914 |
-
def __init__(
|
915 |
-
self,
|
916 |
-
host,
|
917 |
-
port=None,
|
918 |
-
strict=False,
|
919 |
-
timeout=Timeout.DEFAULT_TIMEOUT,
|
920 |
-
maxsize=1,
|
921 |
-
block=False,
|
922 |
-
headers=None,
|
923 |
-
retries=None,
|
924 |
-
_proxy=None,
|
925 |
-
_proxy_headers=None,
|
926 |
-
key_file=None,
|
927 |
-
cert_file=None,
|
928 |
-
cert_reqs=None,
|
929 |
-
key_password=None,
|
930 |
-
ca_certs=None,
|
931 |
-
ssl_version=None,
|
932 |
-
assert_hostname=None,
|
933 |
-
assert_fingerprint=None,
|
934 |
-
ca_cert_dir=None,
|
935 |
-
**conn_kw
|
936 |
-
):
|
937 |
-
|
938 |
-
HTTPConnectionPool.__init__(
|
939 |
-
self,
|
940 |
-
host,
|
941 |
-
port,
|
942 |
-
strict,
|
943 |
-
timeout,
|
944 |
-
maxsize,
|
945 |
-
block,
|
946 |
-
headers,
|
947 |
-
retries,
|
948 |
-
_proxy,
|
949 |
-
_proxy_headers,
|
950 |
-
**conn_kw
|
951 |
-
)
|
952 |
-
|
953 |
-
self.key_file = key_file
|
954 |
-
self.cert_file = cert_file
|
955 |
-
self.cert_reqs = cert_reqs
|
956 |
-
self.key_password = key_password
|
957 |
-
self.ca_certs = ca_certs
|
958 |
-
self.ca_cert_dir = ca_cert_dir
|
959 |
-
self.ssl_version = ssl_version
|
960 |
-
self.assert_hostname = assert_hostname
|
961 |
-
self.assert_fingerprint = assert_fingerprint
|
962 |
-
|
963 |
-
def _prepare_conn(self, conn):
|
964 |
-
"""
|
965 |
-
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket`
|
966 |
-
and establish the tunnel if proxy is used.
|
967 |
-
"""
|
968 |
-
|
969 |
-
if isinstance(conn, VerifiedHTTPSConnection):
|
970 |
-
conn.set_cert(
|
971 |
-
key_file=self.key_file,
|
972 |
-
key_password=self.key_password,
|
973 |
-
cert_file=self.cert_file,
|
974 |
-
cert_reqs=self.cert_reqs,
|
975 |
-
ca_certs=self.ca_certs,
|
976 |
-
ca_cert_dir=self.ca_cert_dir,
|
977 |
-
assert_hostname=self.assert_hostname,
|
978 |
-
assert_fingerprint=self.assert_fingerprint,
|
979 |
-
)
|
980 |
-
conn.ssl_version = self.ssl_version
|
981 |
-
return conn
|
982 |
-
|
983 |
-
def _prepare_proxy(self, conn):
|
984 |
-
"""
|
985 |
-
Establishes a tunnel connection through HTTP CONNECT.
|
986 |
-
|
987 |
-
Tunnel connection is established early because otherwise httplib would
|
988 |
-
improperly set Host: header to proxy's IP:port.
|
989 |
-
"""
|
990 |
-
|
991 |
-
conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers)
|
992 |
-
|
993 |
-
if self.proxy.scheme == "https":
|
994 |
-
conn.tls_in_tls_required = True
|
995 |
-
|
996 |
-
conn.connect()
|
997 |
-
|
998 |
-
def _new_conn(self):
|
999 |
-
"""
|
1000 |
-
Return a fresh :class:`http.client.HTTPSConnection`.
|
1001 |
-
"""
|
1002 |
-
self.num_connections += 1
|
1003 |
-
log.debug(
|
1004 |
-
"Starting new HTTPS connection (%d): %s:%s",
|
1005 |
-
self.num_connections,
|
1006 |
-
self.host,
|
1007 |
-
self.port or "443",
|
1008 |
-
)
|
1009 |
-
|
1010 |
-
if not self.ConnectionCls or self.ConnectionCls is DummyConnection:
|
1011 |
-
raise SSLError(
|
1012 |
-
"Can't connect to HTTPS URL because the SSL module is not available."
|
1013 |
-
)
|
1014 |
-
|
1015 |
-
actual_host = self.host
|
1016 |
-
actual_port = self.port
|
1017 |
-
if self.proxy is not None:
|
1018 |
-
actual_host = self.proxy.host
|
1019 |
-
actual_port = self.proxy.port
|
1020 |
-
|
1021 |
-
conn = self.ConnectionCls(
|
1022 |
-
host=actual_host,
|
1023 |
-
port=actual_port,
|
1024 |
-
timeout=self.timeout.connect_timeout,
|
1025 |
-
strict=self.strict,
|
1026 |
-
cert_file=self.cert_file,
|
1027 |
-
key_file=self.key_file,
|
1028 |
-
key_password=self.key_password,
|
1029 |
-
**self.conn_kw
|
1030 |
-
)
|
1031 |
-
|
1032 |
-
return self._prepare_conn(conn)
|
1033 |
-
|
1034 |
-
def _validate_conn(self, conn):
|
1035 |
-
"""
|
1036 |
-
Called right before a request is made, after the socket is created.
|
1037 |
-
"""
|
1038 |
-
super(HTTPSConnectionPool, self)._validate_conn(conn)
|
1039 |
-
|
1040 |
-
# Force connect early to allow us to validate the connection.
|
1041 |
-
if not getattr(conn, "sock", None): # AppEngine might not have `.sock`
|
1042 |
-
conn.connect()
|
1043 |
-
|
1044 |
-
if not conn.is_verified:
|
1045 |
-
warnings.warn(
|
1046 |
-
(
|
1047 |
-
"Unverified HTTPS request is being made to host '%s'. "
|
1048 |
-
"Adding certificate verification is strongly advised. See: "
|
1049 |
-
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
1050 |
-
"#ssl-warnings" % conn.host
|
1051 |
-
),
|
1052 |
-
InsecureRequestWarning,
|
1053 |
-
)
|
1054 |
-
|
1055 |
-
if getattr(conn, "proxy_is_verified", None) is False:
|
1056 |
-
warnings.warn(
|
1057 |
-
(
|
1058 |
-
"Unverified HTTPS connection done to an HTTPS proxy. "
|
1059 |
-
"Adding certificate verification is strongly advised. See: "
|
1060 |
-
"https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html"
|
1061 |
-
"#ssl-warnings"
|
1062 |
-
),
|
1063 |
-
InsecureRequestWarning,
|
1064 |
-
)
|
1065 |
-
|
1066 |
-
|
1067 |
-
def connection_from_url(url, **kw):
|
1068 |
-
"""
|
1069 |
-
Given a url, return an :class:`.ConnectionPool` instance of its host.
|
1070 |
-
|
1071 |
-
This is a shortcut for not having to parse out the scheme, host, and port
|
1072 |
-
of the url before creating an :class:`.ConnectionPool` instance.
|
1073 |
-
|
1074 |
-
:param url:
|
1075 |
-
Absolute URL string that must include the scheme. Port is optional.
|
1076 |
-
|
1077 |
-
:param \\**kw:
|
1078 |
-
Passes additional parameters to the constructor of the appropriate
|
1079 |
-
:class:`.ConnectionPool`. Useful for specifying things like
|
1080 |
-
timeout, maxsize, headers, etc.
|
1081 |
-
|
1082 |
-
Example::
|
1083 |
-
|
1084 |
-
>>> conn = connection_from_url('http://google.com/')
|
1085 |
-
>>> r = conn.request('GET', '/')
|
1086 |
-
"""
|
1087 |
-
scheme, host, port = get_host(url)
|
1088 |
-
port = port or port_by_scheme.get(scheme, 80)
|
1089 |
-
if scheme == "https":
|
1090 |
-
return HTTPSConnectionPool(host, port=port, **kw)
|
1091 |
-
else:
|
1092 |
-
return HTTPConnectionPool(host, port=port, **kw)
|
1093 |
-
|
1094 |
-
|
1095 |
-
def _normalize_host(host, scheme):
|
1096 |
-
"""
|
1097 |
-
Normalize hosts for comparisons and use with sockets.
|
1098 |
-
"""
|
1099 |
-
|
1100 |
-
host = normalize_host(host, scheme)
|
1101 |
-
|
1102 |
-
# httplib doesn't like it when we include brackets in IPv6 addresses
|
1103 |
-
# Specifically, if we include brackets but also pass the port then
|
1104 |
-
# httplib crazily doubles up the square brackets on the Host header.
|
1105 |
-
# Instead, we need to make sure we never pass ``None`` as the port.
|
1106 |
-
# However, for backward compatibility reasons we can't actually
|
1107 |
-
# *assert* that. See http://bugs.python.org/issue28539
|
1108 |
-
if host.startswith("[") and host.endswith("]"):
|
1109 |
-
host = host[1:-1]
|
1110 |
-
return host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/command/develop.py
DELETED
@@ -1,193 +0,0 @@
|
|
1 |
-
from distutils.util import convert_path
|
2 |
-
from distutils import log
|
3 |
-
from distutils.errors import DistutilsError, DistutilsOptionError
|
4 |
-
import os
|
5 |
-
import glob
|
6 |
-
import io
|
7 |
-
|
8 |
-
import pkg_resources
|
9 |
-
from setuptools.command.easy_install import easy_install
|
10 |
-
from setuptools import namespaces
|
11 |
-
import setuptools
|
12 |
-
|
13 |
-
|
14 |
-
class develop(namespaces.DevelopInstaller, easy_install):
|
15 |
-
"""Set up package for development"""
|
16 |
-
|
17 |
-
description = "install package in 'development mode'"
|
18 |
-
|
19 |
-
user_options = easy_install.user_options + [
|
20 |
-
("uninstall", "u", "Uninstall this source package"),
|
21 |
-
("egg-path=", None, "Set the path to be used in the .egg-link file"),
|
22 |
-
]
|
23 |
-
|
24 |
-
boolean_options = easy_install.boolean_options + ['uninstall']
|
25 |
-
|
26 |
-
command_consumes_arguments = False # override base
|
27 |
-
|
28 |
-
def run(self):
|
29 |
-
if self.uninstall:
|
30 |
-
self.multi_version = True
|
31 |
-
self.uninstall_link()
|
32 |
-
self.uninstall_namespaces()
|
33 |
-
else:
|
34 |
-
self.install_for_development()
|
35 |
-
self.warn_deprecated_options()
|
36 |
-
|
37 |
-
def initialize_options(self):
|
38 |
-
self.uninstall = None
|
39 |
-
self.egg_path = None
|
40 |
-
easy_install.initialize_options(self)
|
41 |
-
self.setup_path = None
|
42 |
-
self.always_copy_from = '.' # always copy eggs installed in curdir
|
43 |
-
|
44 |
-
def finalize_options(self):
|
45 |
-
ei = self.get_finalized_command("egg_info")
|
46 |
-
if ei.broken_egg_info:
|
47 |
-
template = "Please rename %r to %r before using 'develop'"
|
48 |
-
args = ei.egg_info, ei.broken_egg_info
|
49 |
-
raise DistutilsError(template % args)
|
50 |
-
self.args = [ei.egg_name]
|
51 |
-
|
52 |
-
easy_install.finalize_options(self)
|
53 |
-
self.expand_basedirs()
|
54 |
-
self.expand_dirs()
|
55 |
-
# pick up setup-dir .egg files only: no .egg-info
|
56 |
-
self.package_index.scan(glob.glob('*.egg'))
|
57 |
-
|
58 |
-
egg_link_fn = ei.egg_name + '.egg-link'
|
59 |
-
self.egg_link = os.path.join(self.install_dir, egg_link_fn)
|
60 |
-
self.egg_base = ei.egg_base
|
61 |
-
if self.egg_path is None:
|
62 |
-
self.egg_path = os.path.abspath(ei.egg_base)
|
63 |
-
|
64 |
-
target = pkg_resources.normalize_path(self.egg_base)
|
65 |
-
egg_path = pkg_resources.normalize_path(
|
66 |
-
os.path.join(self.install_dir, self.egg_path)
|
67 |
-
)
|
68 |
-
if egg_path != target:
|
69 |
-
raise DistutilsOptionError(
|
70 |
-
"--egg-path must be a relative path from the install"
|
71 |
-
" directory to " + target
|
72 |
-
)
|
73 |
-
|
74 |
-
# Make a distribution for the package's source
|
75 |
-
self.dist = pkg_resources.Distribution(
|
76 |
-
target,
|
77 |
-
pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)),
|
78 |
-
project_name=ei.egg_name,
|
79 |
-
)
|
80 |
-
|
81 |
-
self.setup_path = self._resolve_setup_path(
|
82 |
-
self.egg_base,
|
83 |
-
self.install_dir,
|
84 |
-
self.egg_path,
|
85 |
-
)
|
86 |
-
|
87 |
-
@staticmethod
|
88 |
-
def _resolve_setup_path(egg_base, install_dir, egg_path):
|
89 |
-
"""
|
90 |
-
Generate a path from egg_base back to '.' where the
|
91 |
-
setup script resides and ensure that path points to the
|
92 |
-
setup path from $install_dir/$egg_path.
|
93 |
-
"""
|
94 |
-
path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
|
95 |
-
if path_to_setup != os.curdir:
|
96 |
-
path_to_setup = '../' * (path_to_setup.count('/') + 1)
|
97 |
-
resolved = pkg_resources.normalize_path(
|
98 |
-
os.path.join(install_dir, egg_path, path_to_setup)
|
99 |
-
)
|
100 |
-
if resolved != pkg_resources.normalize_path(os.curdir):
|
101 |
-
raise DistutilsOptionError(
|
102 |
-
"Can't get a consistent path to setup script from"
|
103 |
-
" installation directory",
|
104 |
-
resolved,
|
105 |
-
pkg_resources.normalize_path(os.curdir),
|
106 |
-
)
|
107 |
-
return path_to_setup
|
108 |
-
|
109 |
-
def install_for_development(self):
|
110 |
-
self.run_command('egg_info')
|
111 |
-
|
112 |
-
# Build extensions in-place
|
113 |
-
self.reinitialize_command('build_ext', inplace=1)
|
114 |
-
self.run_command('build_ext')
|
115 |
-
|
116 |
-
if setuptools.bootstrap_install_from:
|
117 |
-
self.easy_install(setuptools.bootstrap_install_from)
|
118 |
-
setuptools.bootstrap_install_from = None
|
119 |
-
|
120 |
-
self.install_namespaces()
|
121 |
-
|
122 |
-
# create an .egg-link in the installation dir, pointing to our egg
|
123 |
-
log.info("Creating %s (link to %s)", self.egg_link, self.egg_base)
|
124 |
-
if not self.dry_run:
|
125 |
-
with open(self.egg_link, "w") as f:
|
126 |
-
f.write(self.egg_path + "\n" + self.setup_path)
|
127 |
-
# postprocess the installed distro, fixing up .pth, installing scripts,
|
128 |
-
# and handling requirements
|
129 |
-
self.process_distribution(None, self.dist, not self.no_deps)
|
130 |
-
|
131 |
-
def uninstall_link(self):
|
132 |
-
if os.path.exists(self.egg_link):
|
133 |
-
log.info("Removing %s (link to %s)", self.egg_link, self.egg_base)
|
134 |
-
egg_link_file = open(self.egg_link)
|
135 |
-
contents = [line.rstrip() for line in egg_link_file]
|
136 |
-
egg_link_file.close()
|
137 |
-
if contents not in ([self.egg_path], [self.egg_path, self.setup_path]):
|
138 |
-
log.warn("Link points to %s: uninstall aborted", contents)
|
139 |
-
return
|
140 |
-
if not self.dry_run:
|
141 |
-
os.unlink(self.egg_link)
|
142 |
-
if not self.dry_run:
|
143 |
-
self.update_pth(self.dist) # remove any .pth link to us
|
144 |
-
if self.distribution.scripts:
|
145 |
-
# XXX should also check for entry point scripts!
|
146 |
-
log.warn("Note: you must uninstall or replace scripts manually!")
|
147 |
-
|
148 |
-
def install_egg_scripts(self, dist):
|
149 |
-
if dist is not self.dist:
|
150 |
-
# Installing a dependency, so fall back to normal behavior
|
151 |
-
return easy_install.install_egg_scripts(self, dist)
|
152 |
-
|
153 |
-
# create wrapper scripts in the script dir, pointing to dist.scripts
|
154 |
-
|
155 |
-
# new-style...
|
156 |
-
self.install_wrapper_scripts(dist)
|
157 |
-
|
158 |
-
# ...and old-style
|
159 |
-
for script_name in self.distribution.scripts or []:
|
160 |
-
script_path = os.path.abspath(convert_path(script_name))
|
161 |
-
script_name = os.path.basename(script_path)
|
162 |
-
with io.open(script_path) as strm:
|
163 |
-
script_text = strm.read()
|
164 |
-
self.install_script(dist, script_name, script_text, script_path)
|
165 |
-
|
166 |
-
def install_wrapper_scripts(self, dist):
|
167 |
-
dist = VersionlessRequirement(dist)
|
168 |
-
return easy_install.install_wrapper_scripts(self, dist)
|
169 |
-
|
170 |
-
|
171 |
-
class VersionlessRequirement:
|
172 |
-
"""
|
173 |
-
Adapt a pkg_resources.Distribution to simply return the project
|
174 |
-
name as the 'requirement' so that scripts will work across
|
175 |
-
multiple versions.
|
176 |
-
|
177 |
-
>>> from pkg_resources import Distribution
|
178 |
-
>>> dist = Distribution(project_name='foo', version='1.0')
|
179 |
-
>>> str(dist.as_requirement())
|
180 |
-
'foo==1.0'
|
181 |
-
>>> adapted_dist = VersionlessRequirement(dist)
|
182 |
-
>>> str(adapted_dist.as_requirement())
|
183 |
-
'foo'
|
184 |
-
"""
|
185 |
-
|
186 |
-
def __init__(self, dist):
|
187 |
-
self.__dist = dist
|
188 |
-
|
189 |
-
def __getattr__(self, name):
|
190 |
-
return getattr(self.__dist, name)
|
191 |
-
|
192 |
-
def as_requirement(self):
|
193 |
-
return self.project_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Big-Web/MMSD/env/Lib/site-packages/setuptools/config/_apply_pyprojecttoml.py
DELETED
@@ -1,377 +0,0 @@
|
|
1 |
-
"""Translation layer between pyproject config and setuptools distribution and
|
2 |
-
metadata objects.
|
3 |
-
|
4 |
-
The distribution and metadata objects are modeled after (an old version of)
|
5 |
-
core metadata, therefore configs in the format specified for ``pyproject.toml``
|
6 |
-
need to be processed before being applied.
|
7 |
-
|
8 |
-
**PRIVATE MODULE**: API reserved for setuptools internal usage only.
|
9 |
-
"""
|
10 |
-
import logging
|
11 |
-
import os
|
12 |
-
import warnings
|
13 |
-
from collections.abc import Mapping
|
14 |
-
from email.headerregistry import Address
|
15 |
-
from functools import partial, reduce
|
16 |
-
from itertools import chain
|
17 |
-
from types import MappingProxyType
|
18 |
-
from typing import (TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple,
|
19 |
-
Type, Union)
|
20 |
-
|
21 |
-
from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
|
22 |
-
|
23 |
-
if TYPE_CHECKING:
|
24 |
-
from setuptools._importlib import metadata # noqa
|
25 |
-
from setuptools.dist import Distribution # noqa
|
26 |
-
|
27 |
-
EMPTY: Mapping = MappingProxyType({}) # Immutable dict-like
|
28 |
-
_Path = Union[os.PathLike, str]
|
29 |
-
_DictOrStr = Union[dict, str]
|
30 |
-
_CorrespFn = Callable[["Distribution", Any, _Path], None]
|
31 |
-
_Correspondence = Union[str, _CorrespFn]
|
32 |
-
|
33 |
-
_logger = logging.getLogger(__name__)
|
34 |
-
|
35 |
-
|
36 |
-
def apply(dist: "Distribution", config: dict, filename: _Path) -> "Distribution":
|
37 |
-
"""Apply configuration dict read with :func:`read_configuration`"""
|
38 |
-
|
39 |
-
if not config:
|
40 |
-
return dist # short-circuit unrelated pyproject.toml file
|
41 |
-
|
42 |
-
root_dir = os.path.dirname(filename) or "."
|
43 |
-
|
44 |
-
_apply_project_table(dist, config, root_dir)
|
45 |
-
_apply_tool_table(dist, config, filename)
|
46 |
-
|
47 |
-
current_directory = os.getcwd()
|
48 |
-
os.chdir(root_dir)
|
49 |
-
try:
|
50 |
-
dist._finalize_requires()
|
51 |
-
dist._finalize_license_files()
|
52 |
-
finally:
|
53 |
-
os.chdir(current_directory)
|
54 |
-
|
55 |
-
return dist
|
56 |
-
|
57 |
-
|
58 |
-
def _apply_project_table(dist: "Distribution", config: dict, root_dir: _Path):
|
59 |
-
project_table = config.get("project", {}).copy()
|
60 |
-
if not project_table:
|
61 |
-
return # short-circuit
|
62 |
-
|
63 |
-
_handle_missing_dynamic(dist, project_table)
|
64 |
-
_unify_entry_points(project_table)
|
65 |
-
|
66 |
-
for field, value in project_table.items():
|
67 |
-
norm_key = json_compatible_key(field)
|
68 |
-
corresp = PYPROJECT_CORRESPONDENCE.get(norm_key, norm_key)
|
69 |
-
if callable(corresp):
|
70 |
-
corresp(dist, value, root_dir)
|
71 |
-
else:
|
72 |
-
_set_config(dist, corresp, value)
|
73 |
-
|
74 |
-
|
75 |
-
def _apply_tool_table(dist: "Distribution", config: dict, filename: _Path):
|
76 |
-
tool_table = config.get("tool", {}).get("setuptools", {})
|
77 |
-
if not tool_table:
|
78 |
-
return # short-circuit
|
79 |
-
|
80 |
-
for field, value in tool_table.items():
|
81 |
-
norm_key = json_compatible_key(field)
|
82 |
-
|
83 |
-
if norm_key in TOOL_TABLE_DEPRECATIONS:
|
84 |
-
suggestion = TOOL_TABLE_DEPRECATIONS[norm_key]
|
85 |
-
msg = f"The parameter `{norm_key}` is deprecated, {suggestion}"
|
86 |
-
warnings.warn(msg, SetuptoolsDeprecationWarning)
|
87 |
-
|
88 |
-
norm_key = TOOL_TABLE_RENAMES.get(norm_key, norm_key)
|
89 |
-
_set_config(dist, norm_key, value)
|
90 |
-
|
91 |
-
_copy_command_options(config, dist, filename)
|
92 |
-
|
93 |
-
|
94 |
-
def _handle_missing_dynamic(dist: "Distribution", project_table: dict):
|
95 |
-
"""Be temporarily forgiving with ``dynamic`` fields not listed in ``dynamic``"""
|
96 |
-
# TODO: Set fields back to `None` once the feature stabilizes
|
97 |
-
dynamic = set(project_table.get("dynamic", []))
|
98 |
-
for field, getter in _PREVIOUSLY_DEFINED.items():
|
99 |
-
if not (field in project_table or field in dynamic):
|
100 |
-
value = getter(dist)
|
101 |
-
if value:
|
102 |
-
msg = _WouldIgnoreField.message(field, value)
|
103 |
-
warnings.warn(msg, _WouldIgnoreField)
|
104 |
-
|
105 |
-
|
106 |
-
def json_compatible_key(key: str) -> str:
|
107 |
-
"""As defined in :pep:`566#json-compatible-metadata`"""
|
108 |
-
return key.lower().replace("-", "_")
|
109 |
-
|
110 |
-
|
111 |
-
def _set_config(dist: "Distribution", field: str, value: Any):
|
112 |
-
setter = getattr(dist.metadata, f"set_{field}", None)
|
113 |
-
if setter:
|
114 |
-
setter(value)
|
115 |
-
elif hasattr(dist.metadata, field) or field in SETUPTOOLS_PATCHES:
|
116 |
-
setattr(dist.metadata, field, value)
|
117 |
-
else:
|
118 |
-
setattr(dist, field, value)
|
119 |
-
|
120 |
-
|
121 |
-
_CONTENT_TYPES = {
|
122 |
-
".md": "text/markdown",
|
123 |
-
".rst": "text/x-rst",
|
124 |
-
".txt": "text/plain",
|
125 |
-
}
|
126 |
-
|
127 |
-
|
128 |
-
def _guess_content_type(file: str) -> Optional[str]:
|
129 |
-
_, ext = os.path.splitext(file.lower())
|
130 |
-
if not ext:
|
131 |
-
return None
|
132 |
-
|
133 |
-
if ext in _CONTENT_TYPES:
|
134 |
-
return _CONTENT_TYPES[ext]
|
135 |
-
|
136 |
-
valid = ", ".join(f"{k} ({v})" for k, v in _CONTENT_TYPES.items())
|
137 |
-
msg = f"only the following file extensions are recognized: {valid}."
|
138 |
-
raise ValueError(f"Undefined content type for {file}, {msg}")
|
139 |
-
|
140 |
-
|
141 |
-
def _long_description(dist: "Distribution", val: _DictOrStr, root_dir: _Path):
|
142 |
-
from setuptools.config import expand
|
143 |
-
|
144 |
-
if isinstance(val, str):
|
145 |
-
text = expand.read_files(val, root_dir)
|
146 |
-
ctype = _guess_content_type(val)
|
147 |
-
else:
|
148 |
-
text = val.get("text") or expand.read_files(val.get("file", []), root_dir)
|
149 |
-
ctype = val["content-type"]
|
150 |
-
|
151 |
-
_set_config(dist, "long_description", text)
|
152 |
-
if ctype:
|
153 |
-
_set_config(dist, "long_description_content_type", ctype)
|
154 |
-
|
155 |
-
|
156 |
-
def _license(dist: "Distribution", val: dict, root_dir: _Path):
|
157 |
-
from setuptools.config import expand
|
158 |
-
|
159 |
-
if "file" in val:
|
160 |
-
_set_config(dist, "license", expand.read_files([val["file"]], root_dir))
|
161 |
-
else:
|
162 |
-
_set_config(dist, "license", val["text"])
|
163 |
-
|
164 |
-
|
165 |
-
def _people(dist: "Distribution", val: List[dict], _root_dir: _Path, kind: str):
|
166 |
-
field = []
|
167 |
-
email_field = []
|
168 |
-
for person in val:
|
169 |
-
if "name" not in person:
|
170 |
-
email_field.append(person["email"])
|
171 |
-
elif "email" not in person:
|
172 |
-
field.append(person["name"])
|
173 |
-
else:
|
174 |
-
addr = Address(display_name=person["name"], addr_spec=person["email"])
|
175 |
-
email_field.append(str(addr))
|
176 |
-
|
177 |
-
if field:
|
178 |
-
_set_config(dist, kind, ", ".join(field))
|
179 |
-
if email_field:
|
180 |
-
_set_config(dist, f"{kind}_email", ", ".join(email_field))
|
181 |
-
|
182 |
-
|
183 |
-
def _project_urls(dist: "Distribution", val: dict, _root_dir):
|
184 |
-
_set_config(dist, "project_urls", val)
|
185 |
-
|
186 |
-
|
187 |
-
def _python_requires(dist: "Distribution", val: dict, _root_dir):
|
188 |
-
from setuptools.extern.packaging.specifiers import SpecifierSet
|
189 |
-
|
190 |
-
_set_config(dist, "python_requires", SpecifierSet(val))
|
191 |
-
|
192 |
-
|
193 |
-
def _dependencies(dist: "Distribution", val: list, _root_dir):
|
194 |
-
if getattr(dist, "install_requires", []):
|
195 |
-
msg = "`install_requires` overwritten in `pyproject.toml` (dependencies)"
|
196 |
-
warnings.warn(msg)
|
197 |
-
_set_config(dist, "install_requires", val)
|
198 |
-
|
199 |
-
|
200 |
-
def _optional_dependencies(dist: "Distribution", val: dict, _root_dir):
|
201 |
-
existing = getattr(dist, "extras_require", {})
|
202 |
-
_set_config(dist, "extras_require", {**existing, **val})
|
203 |
-
|
204 |
-
|
205 |
-
def _unify_entry_points(project_table: dict):
|
206 |
-
project = project_table
|
207 |
-
entry_points = project.pop("entry-points", project.pop("entry_points", {}))
|
208 |
-
renaming = {"scripts": "console_scripts", "gui_scripts": "gui_scripts"}
|
209 |
-
for key, value in list(project.items()): # eager to allow modifications
|
210 |
-
norm_key = json_compatible_key(key)
|
211 |
-
if norm_key in renaming and value:
|
212 |
-
entry_points[renaming[norm_key]] = project.pop(key)
|
213 |
-
|
214 |
-
if entry_points:
|
215 |
-
project["entry-points"] = {
|
216 |
-
name: [f"{k} = {v}" for k, v in group.items()]
|
217 |
-
for name, group in entry_points.items()
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
def _copy_command_options(pyproject: dict, dist: "Distribution", filename: _Path):
|
222 |
-
tool_table = pyproject.get("tool", {})
|
223 |
-
cmdclass = tool_table.get("setuptools", {}).get("cmdclass", {})
|
224 |
-
valid_options = _valid_command_options(cmdclass)
|
225 |
-
|
226 |
-
cmd_opts = dist.command_options
|
227 |
-
for cmd, config in pyproject.get("tool", {}).get("distutils", {}).items():
|
228 |
-
cmd = json_compatible_key(cmd)
|
229 |
-
valid = valid_options.get(cmd, set())
|
230 |
-
cmd_opts.setdefault(cmd, {})
|
231 |
-
for key, value in config.items():
|
232 |
-
key = json_compatible_key(key)
|
233 |
-
cmd_opts[cmd][key] = (str(filename), value)
|
234 |
-
if key not in valid:
|
235 |
-
# To avoid removing options that are specified dynamically we
|
236 |
-
# just log a warn...
|
237 |
-
_logger.warning(f"Command option {cmd}.{key} is not defined")
|
238 |
-
|
239 |
-
|
240 |
-
def _valid_command_options(cmdclass: Mapping = EMPTY) -> Dict[str, Set[str]]:
|
241 |
-
from .._importlib import metadata
|
242 |
-
from setuptools.dist import Distribution
|
243 |
-
|
244 |
-
valid_options = {"global": _normalise_cmd_options(Distribution.global_options)}
|
245 |
-
|
246 |
-
unloaded_entry_points = metadata.entry_points(group='distutils.commands')
|
247 |
-
loaded_entry_points = (_load_ep(ep) for ep in unloaded_entry_points)
|
248 |
-
entry_points = (ep for ep in loaded_entry_points if ep)
|
249 |
-
for cmd, cmd_class in chain(entry_points, cmdclass.items()):
|
250 |
-
opts = valid_options.get(cmd, set())
|
251 |
-
opts = opts | _normalise_cmd_options(getattr(cmd_class, "user_options", []))
|
252 |
-
valid_options[cmd] = opts
|
253 |
-
|
254 |
-
return valid_options
|
255 |
-
|
256 |
-
|
257 |
-
def _load_ep(ep: "metadata.EntryPoint") -> Optional[Tuple[str, Type]]:
|
258 |
-
# Ignore all the errors
|
259 |
-
try:
|
260 |
-
return (ep.name, ep.load())
|
261 |
-
except Exception as ex:
|
262 |
-
msg = f"{ex.__class__.__name__} while trying to load entry-point {ep.name}"
|
263 |
-
_logger.warning(f"{msg}: {ex}")
|
264 |
-
return None
|
265 |
-
|
266 |
-
|
267 |
-
def _normalise_cmd_option_key(name: str) -> str:
|
268 |
-
return json_compatible_key(name).strip("_=")
|
269 |
-
|
270 |
-
|
271 |
-
def _normalise_cmd_options(desc: List[Tuple[str, Optional[str], str]]) -> Set[str]:
|
272 |
-
return {_normalise_cmd_option_key(fancy_option[0]) for fancy_option in desc}
|
273 |
-
|
274 |
-
|
275 |
-
def _attrgetter(attr):
|
276 |
-
"""
|
277 |
-
Similar to ``operator.attrgetter`` but returns None if ``attr`` is not found
|
278 |
-
>>> from types import SimpleNamespace
|
279 |
-
>>> obj = SimpleNamespace(a=42, b=SimpleNamespace(c=13))
|
280 |
-
>>> _attrgetter("a")(obj)
|
281 |
-
42
|
282 |
-
>>> _attrgetter("b.c")(obj)
|
283 |
-
13
|
284 |
-
>>> _attrgetter("d")(obj) is None
|
285 |
-
True
|
286 |
-
"""
|
287 |
-
return partial(reduce, lambda acc, x: getattr(acc, x, None), attr.split("."))
|
288 |
-
|
289 |
-
|
290 |
-
def _some_attrgetter(*items):
|
291 |
-
"""
|
292 |
-
Return the first "truth-y" attribute or None
|
293 |
-
>>> from types import SimpleNamespace
|
294 |
-
>>> obj = SimpleNamespace(a=42, b=SimpleNamespace(c=13))
|
295 |
-
>>> _some_attrgetter("d", "a", "b.c")(obj)
|
296 |
-
42
|
297 |
-
>>> _some_attrgetter("d", "e", "b.c", "a")(obj)
|
298 |
-
13
|
299 |
-
>>> _some_attrgetter("d", "e", "f")(obj) is None
|
300 |
-
True
|
301 |
-
"""
|
302 |
-
def _acessor(obj):
|
303 |
-
values = (_attrgetter(i)(obj) for i in items)
|
304 |
-
return next((i for i in values if i is not None), None)
|
305 |
-
return _acessor
|
306 |
-
|
307 |
-
|
308 |
-
PYPROJECT_CORRESPONDENCE: Dict[str, _Correspondence] = {
|
309 |
-
"readme": _long_description,
|
310 |
-
"license": _license,
|
311 |
-
"authors": partial(_people, kind="author"),
|
312 |
-
"maintainers": partial(_people, kind="maintainer"),
|
313 |
-
"urls": _project_urls,
|
314 |
-
"dependencies": _dependencies,
|
315 |
-
"optional_dependencies": _optional_dependencies,
|
316 |
-
"requires_python": _python_requires,
|
317 |
-
}
|
318 |
-
|
319 |
-
TOOL_TABLE_RENAMES = {"script_files": "scripts"}
|
320 |
-
TOOL_TABLE_DEPRECATIONS = {
|
321 |
-
"namespace_packages": "consider using implicit namespaces instead (PEP 420)."
|
322 |
-
}
|
323 |
-
|
324 |
-
SETUPTOOLS_PATCHES = {"long_description_content_type", "project_urls",
|
325 |
-
"provides_extras", "license_file", "license_files"}
|
326 |
-
|
327 |
-
_PREVIOUSLY_DEFINED = {
|
328 |
-
"name": _attrgetter("metadata.name"),
|
329 |
-
"version": _attrgetter("metadata.version"),
|
330 |
-
"description": _attrgetter("metadata.description"),
|
331 |
-
"readme": _attrgetter("metadata.long_description"),
|
332 |
-
"requires-python": _some_attrgetter("python_requires", "metadata.python_requires"),
|
333 |
-
"license": _attrgetter("metadata.license"),
|
334 |
-
"authors": _some_attrgetter("metadata.author", "metadata.author_email"),
|
335 |
-
"maintainers": _some_attrgetter("metadata.maintainer", "metadata.maintainer_email"),
|
336 |
-
"keywords": _attrgetter("metadata.keywords"),
|
337 |
-
"classifiers": _attrgetter("metadata.classifiers"),
|
338 |
-
"urls": _attrgetter("metadata.project_urls"),
|
339 |
-
"entry-points": _attrgetter("entry_points"),
|
340 |
-
"dependencies": _some_attrgetter("_orig_install_requires", "install_requires"),
|
341 |
-
"optional-dependencies": _some_attrgetter("_orig_extras_require", "extras_require"),
|
342 |
-
}
|
343 |
-
|
344 |
-
|
345 |
-
class _WouldIgnoreField(UserWarning):
|
346 |
-
"""Inform users that ``pyproject.toml`` would overwrite previous metadata."""
|
347 |
-
|
348 |
-
MESSAGE = """\
|
349 |
-
{field!r} defined outside of `pyproject.toml` would be ignored.
|
350 |
-
!!\n\n
|
351 |
-
##########################################################################
|
352 |
-
# configuration would be ignored/result in error due to `pyproject.toml` #
|
353 |
-
##########################################################################
|
354 |
-
|
355 |
-
The following seems to be defined outside of `pyproject.toml`:
|
356 |
-
|
357 |
-
`{field} = {value!r}`
|
358 |
-
|
359 |
-
According to the spec (see the link below), however, setuptools CANNOT
|
360 |
-
consider this value unless {field!r} is listed as `dynamic`.
|
361 |
-
|
362 |
-
https://packaging.python.org/en/latest/specifications/declaring-project-metadata/
|
363 |
-
|
364 |
-
For the time being, `setuptools` will still consider the given value (as a
|
365 |
-
**transitional** measure), but please note that future releases of setuptools will
|
366 |
-
follow strictly the standard.
|
367 |
-
|
368 |
-
To prevent this warning, you can list {field!r} under `dynamic` or alternatively
|
369 |
-
remove the `[project]` table from your file and rely entirely on other means of
|
370 |
-
configuration.
|
371 |
-
\n\n!!
|
372 |
-
"""
|
373 |
-
|
374 |
-
@classmethod
|
375 |
-
def message(cls, field, value):
|
376 |
-
from inspect import cleandoc
|
377 |
-
return cleandoc(cls.MESSAGE.format(field=field, value=value))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Blessing/Asphalt-Pavement-Distresses-Detector/README.md
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Asphalt Pavement Distresses Detector
|
3 |
-
emoji: 📊
|
4 |
-
colorFrom: pink
|
5 |
-
colorTo: red
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.39.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
license: mit
|
11 |
-
---
|
12 |
-
|
13 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Bonosa2/movies/README.md
DELETED
@@ -1,12 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: Movies
|
3 |
-
emoji: 🐨
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: yellow
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 3.29.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
-
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/Dual-Key_Backdoor_Attacks/datagen/grid-feats-vqa/CONTRIBUTING.md
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
# Contributing to grid-feats-vqa
|
2 |
-
We want to make contributing to this project as easy and transparent as
|
3 |
-
possible.
|
4 |
-
|
5 |
-
## Pull Requests
|
6 |
-
We actively welcome your pull requests.
|
7 |
-
|
8 |
-
1. Fork the repo and create your branch from `master`.
|
9 |
-
2. If you've added code that should be tested, add tests.
|
10 |
-
3. If you've changed APIs, update the documentation.
|
11 |
-
4. Ensure the test suite passes.
|
12 |
-
5. Make sure your code lints.
|
13 |
-
6. If you haven't already, complete the Contributor License Agreement ("CLA").
|
14 |
-
|
15 |
-
## Contributor License Agreement ("CLA")
|
16 |
-
In order to accept your pull request, we need you to submit a CLA. You only need
|
17 |
-
to do this once to work on any of Facebook's open source projects.
|
18 |
-
|
19 |
-
Complete your CLA here: <https://code.facebook.com/cla>
|
20 |
-
|
21 |
-
## Issues
|
22 |
-
We use GitHub issues to track public bugs. Please ensure your description is
|
23 |
-
clear and has sufficient instructions to be able to reproduce the issue.
|
24 |
-
|
25 |
-
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
|
26 |
-
disclosure of security bugs. In those cases, please go through the process
|
27 |
-
outlined on that page and do not file a public issue.
|
28 |
-
|
29 |
-
## Coding Style
|
30 |
-
* 4 spaces for indentation rather than tabs
|
31 |
-
|
32 |
-
## License
|
33 |
-
By contributing to grid-feats-vqa, you agree that your contributions will be licensed
|
34 |
-
under the LICENSE file in the root directory of this source tree.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/LIVE/pybind11/include/pybind11/operators.h
DELETED
@@ -1,173 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
pybind11/operator.h: Metatemplates for operator overloading
|
3 |
-
|
4 |
-
Copyright (c) 2016 Wenzel Jakob <[email protected]>
|
5 |
-
|
6 |
-
All rights reserved. Use of this source code is governed by a
|
7 |
-
BSD-style license that can be found in the LICENSE file.
|
8 |
-
*/
|
9 |
-
|
10 |
-
#pragma once
|
11 |
-
|
12 |
-
#include "pybind11.h"
|
13 |
-
|
14 |
-
#if defined(__clang__) && !defined(__INTEL_COMPILER)
|
15 |
-
# pragma clang diagnostic ignored "-Wunsequenced" // multiple unsequenced modifications to 'self' (when using def(py::self OP Type()))
|
16 |
-
#elif defined(_MSC_VER)
|
17 |
-
# pragma warning(push)
|
18 |
-
# pragma warning(disable: 4127) // warning C4127: Conditional expression is constant
|
19 |
-
#endif
|
20 |
-
|
21 |
-
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
22 |
-
PYBIND11_NAMESPACE_BEGIN(detail)
|
23 |
-
|
24 |
-
/// Enumeration with all supported operator types
|
25 |
-
enum op_id : int {
|
26 |
-
op_add, op_sub, op_mul, op_div, op_mod, op_divmod, op_pow, op_lshift,
|
27 |
-
op_rshift, op_and, op_xor, op_or, op_neg, op_pos, op_abs, op_invert,
|
28 |
-
op_int, op_long, op_float, op_str, op_cmp, op_gt, op_ge, op_lt, op_le,
|
29 |
-
op_eq, op_ne, op_iadd, op_isub, op_imul, op_idiv, op_imod, op_ilshift,
|
30 |
-
op_irshift, op_iand, op_ixor, op_ior, op_complex, op_bool, op_nonzero,
|
31 |
-
op_repr, op_truediv, op_itruediv, op_hash
|
32 |
-
};
|
33 |
-
|
34 |
-
enum op_type : int {
|
35 |
-
op_l, /* base type on left */
|
36 |
-
op_r, /* base type on right */
|
37 |
-
op_u /* unary operator */
|
38 |
-
};
|
39 |
-
|
40 |
-
struct self_t { };
|
41 |
-
static const self_t self = self_t();
|
42 |
-
|
43 |
-
/// Type for an unused type slot
|
44 |
-
struct undefined_t { };
|
45 |
-
|
46 |
-
/// Don't warn about an unused variable
|
47 |
-
inline self_t __self() { return self; }
|
48 |
-
|
49 |
-
/// base template of operator implementations
|
50 |
-
template <op_id, op_type, typename B, typename L, typename R> struct op_impl { };
|
51 |
-
|
52 |
-
/// Operator implementation generator
|
53 |
-
template <op_id id, op_type ot, typename L, typename R> struct op_ {
|
54 |
-
template <typename Class, typename... Extra> void execute(Class &cl, const Extra&... extra) const {
|
55 |
-
using Base = typename Class::type;
|
56 |
-
using L_type = conditional_t<std::is_same<L, self_t>::value, Base, L>;
|
57 |
-
using R_type = conditional_t<std::is_same<R, self_t>::value, Base, R>;
|
58 |
-
using op = op_impl<id, ot, Base, L_type, R_type>;
|
59 |
-
cl.def(op::name(), &op::execute, is_operator(), extra...);
|
60 |
-
#if PY_MAJOR_VERSION < 3
|
61 |
-
if (id == op_truediv || id == op_itruediv)
|
62 |
-
cl.def(id == op_itruediv ? "__idiv__" : ot == op_l ? "__div__" : "__rdiv__",
|
63 |
-
&op::execute, is_operator(), extra...);
|
64 |
-
#endif
|
65 |
-
}
|
66 |
-
template <typename Class, typename... Extra> void execute_cast(Class &cl, const Extra&... extra) const {
|
67 |
-
using Base = typename Class::type;
|
68 |
-
using L_type = conditional_t<std::is_same<L, self_t>::value, Base, L>;
|
69 |
-
using R_type = conditional_t<std::is_same<R, self_t>::value, Base, R>;
|
70 |
-
using op = op_impl<id, ot, Base, L_type, R_type>;
|
71 |
-
cl.def(op::name(), &op::execute_cast, is_operator(), extra...);
|
72 |
-
#if PY_MAJOR_VERSION < 3
|
73 |
-
if (id == op_truediv || id == op_itruediv)
|
74 |
-
cl.def(id == op_itruediv ? "__idiv__" : ot == op_l ? "__div__" : "__rdiv__",
|
75 |
-
&op::execute, is_operator(), extra...);
|
76 |
-
#endif
|
77 |
-
}
|
78 |
-
};
|
79 |
-
|
80 |
-
#define PYBIND11_BINARY_OPERATOR(id, rid, op, expr) \
|
81 |
-
template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \
|
82 |
-
static char const* name() { return "__" #id "__"; } \
|
83 |
-
static auto execute(const L &l, const R &r) -> decltype(expr) { return (expr); } \
|
84 |
-
static B execute_cast(const L &l, const R &r) { return B(expr); } \
|
85 |
-
}; \
|
86 |
-
template <typename B, typename L, typename R> struct op_impl<op_##id, op_r, B, L, R> { \
|
87 |
-
static char const* name() { return "__" #rid "__"; } \
|
88 |
-
static auto execute(const R &r, const L &l) -> decltype(expr) { return (expr); } \
|
89 |
-
static B execute_cast(const R &r, const L &l) { return B(expr); } \
|
90 |
-
}; \
|
91 |
-
inline op_<op_##id, op_l, self_t, self_t> op(const self_t &, const self_t &) { \
|
92 |
-
return op_<op_##id, op_l, self_t, self_t>(); \
|
93 |
-
} \
|
94 |
-
template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
|
95 |
-
return op_<op_##id, op_l, self_t, T>(); \
|
96 |
-
} \
|
97 |
-
template <typename T> op_<op_##id, op_r, T, self_t> op(const T &, const self_t &) { \
|
98 |
-
return op_<op_##id, op_r, T, self_t>(); \
|
99 |
-
}
|
100 |
-
|
101 |
-
#define PYBIND11_INPLACE_OPERATOR(id, op, expr) \
|
102 |
-
template <typename B, typename L, typename R> struct op_impl<op_##id, op_l, B, L, R> { \
|
103 |
-
static char const* name() { return "__" #id "__"; } \
|
104 |
-
static auto execute(L &l, const R &r) -> decltype(expr) { return expr; } \
|
105 |
-
static B execute_cast(L &l, const R &r) { return B(expr); } \
|
106 |
-
}; \
|
107 |
-
template <typename T> op_<op_##id, op_l, self_t, T> op(const self_t &, const T &) { \
|
108 |
-
return op_<op_##id, op_l, self_t, T>(); \
|
109 |
-
}
|
110 |
-
|
111 |
-
#define PYBIND11_UNARY_OPERATOR(id, op, expr) \
|
112 |
-
template <typename B, typename L> struct op_impl<op_##id, op_u, B, L, undefined_t> { \
|
113 |
-
static char const* name() { return "__" #id "__"; } \
|
114 |
-
static auto execute(const L &l) -> decltype(expr) { return expr; } \
|
115 |
-
static B execute_cast(const L &l) { return B(expr); } \
|
116 |
-
}; \
|
117 |
-
inline op_<op_##id, op_u, self_t, undefined_t> op(const self_t &) { \
|
118 |
-
return op_<op_##id, op_u, self_t, undefined_t>(); \
|
119 |
-
}
|
120 |
-
|
121 |
-
PYBIND11_BINARY_OPERATOR(sub, rsub, operator-, l - r)
|
122 |
-
PYBIND11_BINARY_OPERATOR(add, radd, operator+, l + r)
|
123 |
-
PYBIND11_BINARY_OPERATOR(mul, rmul, operator*, l * r)
|
124 |
-
PYBIND11_BINARY_OPERATOR(truediv, rtruediv, operator/, l / r)
|
125 |
-
PYBIND11_BINARY_OPERATOR(mod, rmod, operator%, l % r)
|
126 |
-
PYBIND11_BINARY_OPERATOR(lshift, rlshift, operator<<, l << r)
|
127 |
-
PYBIND11_BINARY_OPERATOR(rshift, rrshift, operator>>, l >> r)
|
128 |
-
PYBIND11_BINARY_OPERATOR(and, rand, operator&, l & r)
|
129 |
-
PYBIND11_BINARY_OPERATOR(xor, rxor, operator^, l ^ r)
|
130 |
-
PYBIND11_BINARY_OPERATOR(eq, eq, operator==, l == r)
|
131 |
-
PYBIND11_BINARY_OPERATOR(ne, ne, operator!=, l != r)
|
132 |
-
PYBIND11_BINARY_OPERATOR(or, ror, operator|, l | r)
|
133 |
-
PYBIND11_BINARY_OPERATOR(gt, lt, operator>, l > r)
|
134 |
-
PYBIND11_BINARY_OPERATOR(ge, le, operator>=, l >= r)
|
135 |
-
PYBIND11_BINARY_OPERATOR(lt, gt, operator<, l < r)
|
136 |
-
PYBIND11_BINARY_OPERATOR(le, ge, operator<=, l <= r)
|
137 |
-
//PYBIND11_BINARY_OPERATOR(pow, rpow, pow, std::pow(l, r))
|
138 |
-
PYBIND11_INPLACE_OPERATOR(iadd, operator+=, l += r)
|
139 |
-
PYBIND11_INPLACE_OPERATOR(isub, operator-=, l -= r)
|
140 |
-
PYBIND11_INPLACE_OPERATOR(imul, operator*=, l *= r)
|
141 |
-
PYBIND11_INPLACE_OPERATOR(itruediv, operator/=, l /= r)
|
142 |
-
PYBIND11_INPLACE_OPERATOR(imod, operator%=, l %= r)
|
143 |
-
PYBIND11_INPLACE_OPERATOR(ilshift, operator<<=, l <<= r)
|
144 |
-
PYBIND11_INPLACE_OPERATOR(irshift, operator>>=, l >>= r)
|
145 |
-
PYBIND11_INPLACE_OPERATOR(iand, operator&=, l &= r)
|
146 |
-
PYBIND11_INPLACE_OPERATOR(ixor, operator^=, l ^= r)
|
147 |
-
PYBIND11_INPLACE_OPERATOR(ior, operator|=, l |= r)
|
148 |
-
PYBIND11_UNARY_OPERATOR(neg, operator-, -l)
|
149 |
-
PYBIND11_UNARY_OPERATOR(pos, operator+, +l)
|
150 |
-
// WARNING: This usage of `abs` should only be done for existing STL overloads.
|
151 |
-
// Adding overloads directly in to the `std::` namespace is advised against:
|
152 |
-
// https://en.cppreference.com/w/cpp/language/extending_std
|
153 |
-
PYBIND11_UNARY_OPERATOR(abs, abs, std::abs(l))
|
154 |
-
PYBIND11_UNARY_OPERATOR(hash, hash, std::hash<L>()(l))
|
155 |
-
PYBIND11_UNARY_OPERATOR(invert, operator~, (~l))
|
156 |
-
PYBIND11_UNARY_OPERATOR(bool, operator!, !!l)
|
157 |
-
PYBIND11_UNARY_OPERATOR(int, int_, (int) l)
|
158 |
-
PYBIND11_UNARY_OPERATOR(float, float_, (double) l)
|
159 |
-
|
160 |
-
#undef PYBIND11_BINARY_OPERATOR
|
161 |
-
#undef PYBIND11_INPLACE_OPERATOR
|
162 |
-
#undef PYBIND11_UNARY_OPERATOR
|
163 |
-
PYBIND11_NAMESPACE_END(detail)
|
164 |
-
|
165 |
-
using detail::self;
|
166 |
-
// Add named operators so that they are accessible via `py::`.
|
167 |
-
using detail::hash;
|
168 |
-
|
169 |
-
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
170 |
-
|
171 |
-
#if defined(_MSC_VER)
|
172 |
-
# pragma warning(pop)
|
173 |
-
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CVPR/LIVE/thrust/thrust/system/detail/sequential/unique_by_key.h
DELETED
@@ -1,116 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
* Copyright 2008-2013 NVIDIA Corporation
|
3 |
-
*
|
4 |
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
5 |
-
* you may not use this file except in compliance with the License.
|
6 |
-
* You may obtain a copy of the License at
|
7 |
-
*
|
8 |
-
* http://www.apache.org/licenses/LICENSE-2.0
|
9 |
-
*
|
10 |
-
* Unless required by applicable law or agreed to in writing, software
|
11 |
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
12 |
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
-
* See the License for the specific language governing permissions and
|
14 |
-
* limitations under the License.
|
15 |
-
*/
|
16 |
-
|
17 |
-
|
18 |
-
/*! \file unique_by_key.h
|
19 |
-
* \brief Sequential implementations of unique_by_key algorithms.
|
20 |
-
*/
|
21 |
-
|
22 |
-
#pragma once
|
23 |
-
|
24 |
-
#include <thrust/detail/config.h>
|
25 |
-
#include <thrust/system/detail/sequential/execution_policy.h>
|
26 |
-
#include <thrust/iterator/iterator_traits.h>
|
27 |
-
#include <thrust/pair.h>
|
28 |
-
|
29 |
-
namespace thrust
|
30 |
-
{
|
31 |
-
namespace system
|
32 |
-
{
|
33 |
-
namespace detail
|
34 |
-
{
|
35 |
-
namespace sequential
|
36 |
-
{
|
37 |
-
|
38 |
-
|
39 |
-
__thrust_exec_check_disable__
|
40 |
-
template<typename DerivedPolicy,
|
41 |
-
typename InputIterator1,
|
42 |
-
typename InputIterator2,
|
43 |
-
typename OutputIterator1,
|
44 |
-
typename OutputIterator2,
|
45 |
-
typename BinaryPredicate>
|
46 |
-
__host__ __device__
|
47 |
-
thrust::pair<OutputIterator1,OutputIterator2>
|
48 |
-
unique_by_key_copy(sequential::execution_policy<DerivedPolicy> &,
|
49 |
-
InputIterator1 keys_first,
|
50 |
-
InputIterator1 keys_last,
|
51 |
-
InputIterator2 values_first,
|
52 |
-
OutputIterator1 keys_output,
|
53 |
-
OutputIterator2 values_output,
|
54 |
-
BinaryPredicate binary_pred)
|
55 |
-
{
|
56 |
-
typedef typename thrust::iterator_traits<InputIterator1>::value_type InputKeyType;
|
57 |
-
typedef typename thrust::iterator_traits<OutputIterator2>::value_type OutputValueType;
|
58 |
-
|
59 |
-
if(keys_first != keys_last)
|
60 |
-
{
|
61 |
-
InputKeyType temp_key = *keys_first;
|
62 |
-
OutputValueType temp_value = *values_first;
|
63 |
-
|
64 |
-
for(++keys_first, ++values_first;
|
65 |
-
keys_first != keys_last;
|
66 |
-
++keys_first, ++values_first)
|
67 |
-
{
|
68 |
-
InputKeyType key = *keys_first;
|
69 |
-
OutputValueType value = *values_first;
|
70 |
-
|
71 |
-
if(!binary_pred(temp_key, key))
|
72 |
-
{
|
73 |
-
*keys_output = temp_key;
|
74 |
-
*values_output = temp_value;
|
75 |
-
|
76 |
-
++keys_output;
|
77 |
-
++values_output;
|
78 |
-
|
79 |
-
temp_key = key;
|
80 |
-
temp_value = value;
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
*keys_output = temp_key;
|
85 |
-
*values_output = temp_value;
|
86 |
-
|
87 |
-
++keys_output;
|
88 |
-
++values_output;
|
89 |
-
}
|
90 |
-
|
91 |
-
return thrust::make_pair(keys_output, values_output);
|
92 |
-
} // end unique_by_key_copy()
|
93 |
-
|
94 |
-
|
95 |
-
template<typename DerivedPolicy,
|
96 |
-
typename ForwardIterator1,
|
97 |
-
typename ForwardIterator2,
|
98 |
-
typename BinaryPredicate>
|
99 |
-
__host__ __device__
|
100 |
-
thrust::pair<ForwardIterator1,ForwardIterator2>
|
101 |
-
unique_by_key(sequential::execution_policy<DerivedPolicy> &exec,
|
102 |
-
ForwardIterator1 keys_first,
|
103 |
-
ForwardIterator1 keys_last,
|
104 |
-
ForwardIterator2 values_first,
|
105 |
-
BinaryPredicate binary_pred)
|
106 |
-
{
|
107 |
-
// sequential unique_by_key_copy() permits in-situ operation
|
108 |
-
return sequential::unique_by_key_copy(exec, keys_first, keys_last, values_first, keys_first, values_first, binary_pred);
|
109 |
-
} // end unique_by_key()
|
110 |
-
|
111 |
-
|
112 |
-
} // end namespace sequential
|
113 |
-
} // end namespace detail
|
114 |
-
} // end namespace system
|
115 |
-
} // end namespace thrust
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CarlDennis/Lovelive-VITS-JPZH/utils.py
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
import logging
|
2 |
-
from json import loads
|
3 |
-
from torch import load, FloatTensor
|
4 |
-
from numpy import float32
|
5 |
-
import librosa
|
6 |
-
|
7 |
-
|
8 |
-
class HParams():
|
9 |
-
def __init__(self, **kwargs):
|
10 |
-
for k, v in kwargs.items():
|
11 |
-
if type(v) == dict:
|
12 |
-
v = HParams(**v)
|
13 |
-
self[k] = v
|
14 |
-
|
15 |
-
def keys(self):
|
16 |
-
return self.__dict__.keys()
|
17 |
-
|
18 |
-
def items(self):
|
19 |
-
return self.__dict__.items()
|
20 |
-
|
21 |
-
def values(self):
|
22 |
-
return self.__dict__.values()
|
23 |
-
|
24 |
-
def __len__(self):
|
25 |
-
return len(self.__dict__)
|
26 |
-
|
27 |
-
def __getitem__(self, key):
|
28 |
-
return getattr(self, key)
|
29 |
-
|
30 |
-
def __setitem__(self, key, value):
|
31 |
-
return setattr(self, key, value)
|
32 |
-
|
33 |
-
def __contains__(self, key):
|
34 |
-
return key in self.__dict__
|
35 |
-
|
36 |
-
def __repr__(self):
|
37 |
-
return self.__dict__.__repr__()
|
38 |
-
|
39 |
-
|
40 |
-
def load_checkpoint(checkpoint_path, model):
|
41 |
-
checkpoint_dict = load(checkpoint_path, map_location='cpu')
|
42 |
-
iteration = checkpoint_dict['iteration']
|
43 |
-
saved_state_dict = checkpoint_dict['model']
|
44 |
-
if hasattr(model, 'module'):
|
45 |
-
state_dict = model.module.state_dict()
|
46 |
-
else:
|
47 |
-
state_dict = model.state_dict()
|
48 |
-
new_state_dict = {}
|
49 |
-
for k, v in state_dict.items():
|
50 |
-
try:
|
51 |
-
new_state_dict[k] = saved_state_dict[k]
|
52 |
-
except:
|
53 |
-
logging.info("%s is not in the checkpoint" % k)
|
54 |
-
new_state_dict[k] = v
|
55 |
-
pass
|
56 |
-
if hasattr(model, 'module'):
|
57 |
-
model.module.load_state_dict(new_state_dict)
|
58 |
-
else:
|
59 |
-
model.load_state_dict(new_state_dict)
|
60 |
-
logging.info("Loaded checkpoint '{}' (iteration {})".format(
|
61 |
-
checkpoint_path, iteration))
|
62 |
-
return
|
63 |
-
|
64 |
-
|
65 |
-
def get_hparams_from_file(config_path):
|
66 |
-
with open(config_path, "r") as f:
|
67 |
-
data = f.read()
|
68 |
-
config = loads(data)
|
69 |
-
|
70 |
-
hparams = HParams(**config)
|
71 |
-
return hparams
|
72 |
-
|
73 |
-
|
74 |
-
def load_audio_to_torch(full_path, target_sampling_rate):
|
75 |
-
audio, sampling_rate = librosa.load(full_path, sr=target_sampling_rate, mono=True)
|
76 |
-
return FloatTensor(audio.astype(float32))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/Carlosito16/aitGPT/app.py
DELETED
@@ -1,328 +0,0 @@
|
|
1 |
-
#This version includes the memory and custom prompt, representing the final version
|
2 |
-
|
3 |
-
import streamlit as st
|
4 |
-
from streamlit_chat import message as st_message
|
5 |
-
import pandas as pd
|
6 |
-
import numpy as np
|
7 |
-
import datetime
|
8 |
-
import gspread
|
9 |
-
import pickle
|
10 |
-
import os
|
11 |
-
import csv
|
12 |
-
import json
|
13 |
-
import torch
|
14 |
-
from tqdm.auto import tqdm
|
15 |
-
from transformers import BitsAndBytesConfig
|
16 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline, T5Tokenizer, AutoModel, T5ForConditionalGeneration
|
17 |
-
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
18 |
-
|
19 |
-
|
20 |
-
# from langchain.vectorstores import Chroma
|
21 |
-
from langchain.vectorstores import FAISS
|
22 |
-
from langchain.embeddings import HuggingFaceInstructEmbeddings
|
23 |
-
|
24 |
-
|
25 |
-
from langchain import HuggingFacePipeline
|
26 |
-
from langchain.chains import RetrievalQA
|
27 |
-
from langchain.prompts import PromptTemplate
|
28 |
-
from langchain.memory import ConversationBufferWindowMemory
|
29 |
-
|
30 |
-
|
31 |
-
from langchain.chains import LLMChain
|
32 |
-
from langchain.chains import ConversationalRetrievalChain
|
33 |
-
from langchain.chains.question_answering import load_qa_chain
|
34 |
-
from langchain.chains.conversational_retrieval.prompts import CONDENSE_QUESTION_PROMPT
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
prompt_template = """
|
41 |
-
|
42 |
-
You are the chatbot and the face of Asian Institute of Technology (AIT). Your job is to give answers to prospective and current students about the school.
|
43 |
-
Your job is to answer questions only and only related to the AIT. Anything unrelated should be responded with the fact that your main job is solely to provide assistance regarding AIT.
|
44 |
-
MUST only use the following pieces of context to answer the question at the end. If the answers are not in the context or you are not sure of the answer, just say that you don't know, don't try to make up an answer.
|
45 |
-
|
46 |
-
|
47 |
-
{context}
|
48 |
-
Question: {question}
|
49 |
-
|
50 |
-
When encountering abusive, offensive, or harmful language, such as fuck, bitch,etc, just politely ask the users to maintain appropriate behaviours.
|
51 |
-
Always make sure to elaborate your response and use vibrant, positive tone to represent good branding of the school.
|
52 |
-
Never answer with any unfinished response
|
53 |
-
|
54 |
-
Answer:
|
55 |
-
"""
|
56 |
-
PROMPT = PromptTemplate(
|
57 |
-
template=prompt_template, input_variables=["context", "question"]
|
58 |
-
)
|
59 |
-
chain_type_kwargs = {"prompt": PROMPT}
|
60 |
-
|
61 |
-
|
62 |
-
st.set_page_config(
|
63 |
-
page_title = 'aitGPT',
|
64 |
-
page_icon = '✅')
|
65 |
-
|
66 |
-
bitsandbyte_config = BitsAndBytesConfig(
|
67 |
-
load_in_4bit=True,
|
68 |
-
bnb_4bit_quant_type="nf4",
|
69 |
-
bnb_4bit_compute_dtype=torch.float16)
|
70 |
-
|
71 |
-
|
72 |
-
@st.cache_data
|
73 |
-
def load_scraped_web_info():
|
74 |
-
with open("ait-web-document", "rb") as fp:
|
75 |
-
ait_web_documents = pickle.load(fp)
|
76 |
-
|
77 |
-
|
78 |
-
text_splitter = RecursiveCharacterTextSplitter(
|
79 |
-
# Set a really small chunk size, just to show.
|
80 |
-
chunk_size = 500,
|
81 |
-
chunk_overlap = 100,
|
82 |
-
length_function = len,
|
83 |
-
)
|
84 |
-
|
85 |
-
chunked_text = text_splitter.create_documents([doc for doc in tqdm(ait_web_documents)])
|
86 |
-
|
87 |
-
|
88 |
-
@st.cache_resource
|
89 |
-
def load_embedding_model():
|
90 |
-
embedding_model = HuggingFaceInstructEmbeddings(model_name='hkunlp/instructor-base',
|
91 |
-
model_kwargs = {'device': torch.device('cuda' if torch.cuda.is_available() else 'cpu')})
|
92 |
-
return embedding_model
|
93 |
-
|
94 |
-
@st.cache_data
|
95 |
-
def load_faiss_index():
|
96 |
-
vector_database = FAISS.load_local("faiss_index_web_and_curri_new", embedding_model) #CHANGE THIS FAISS EMBEDDED KNOWLEDGE
|
97 |
-
return vector_database
|
98 |
-
|
99 |
-
@st.cache_resource
|
100 |
-
def load_llm_model():
|
101 |
-
#this one is for running with GPU
|
102 |
-
|
103 |
-
model = T5ForConditionalGeneration.from_pretrained('lmsys/fastchat-t5-3b-v1.0',
|
104 |
-
quantization_config = bitsandbyte_config,
|
105 |
-
device_map= 'auto')
|
106 |
-
tokenizer = AutoTokenizer.from_pretrained('lmsys/fastchat-t5-3b-v1.0')
|
107 |
-
|
108 |
-
|
109 |
-
pipe = pipeline(
|
110 |
-
task= 'text2text-generation', model=model, tokenizer=tokenizer, max_new_tokens=256, model_kwargs={"temperature":0,
|
111 |
-
"repetition_penalty": 1.5}
|
112 |
-
)
|
113 |
-
llm = HuggingFacePipeline(pipeline=pipe)
|
114 |
-
|
115 |
-
# llm = HuggingFacePipeline.from_model_id(model_id= 'lmsys/fastchat-t5-3b-v1.0',
|
116 |
-
# task= 'text2text-generation',
|
117 |
-
# model_kwargs={
|
118 |
-
# # "device_map": "auto",
|
119 |
-
# "max_length": 256, "temperature": 0,
|
120 |
-
# "repetition_penalty": 1.5,
|
121 |
-
# "quantization_config": bitsandbyte_config}) #add this quantization config
|
122 |
-
|
123 |
-
|
124 |
-
# llm = HuggingFacePipeline.from_model_id(model_id= 'lmsys/fastchat-t5-3b-v1.0',
|
125 |
-
# task= 'text2text-generation',
|
126 |
-
|
127 |
-
# model_kwargs={ "max_length": 256, "temperature": 0,
|
128 |
-
# "torch_dtype":torch.float32,
|
129 |
-
# "repetition_penalty": 1.3})
|
130 |
-
return llm
|
131 |
-
|
132 |
-
|
133 |
-
@st.cache_resource
|
134 |
-
def load_conversational_qa_memory_retriever():
|
135 |
-
|
136 |
-
question_generator = LLMChain(llm=llm_model, prompt=CONDENSE_QUESTION_PROMPT)
|
137 |
-
doc_chain = load_qa_chain(llm_model, chain_type="stuff", prompt = PROMPT)
|
138 |
-
memory = ConversationBufferWindowMemory(k = 3, memory_key="chat_history", return_messages=True, output_key='answer')
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
conversational_qa_memory_retriever = ConversationalRetrievalChain(
|
143 |
-
retriever=vector_database.as_retriever(),
|
144 |
-
question_generator=question_generator,
|
145 |
-
combine_docs_chain=doc_chain,
|
146 |
-
return_source_documents=True,
|
147 |
-
memory = memory,
|
148 |
-
get_chat_history=lambda h :h)
|
149 |
-
return conversational_qa_memory_retriever, question_generator
|
150 |
-
|
151 |
-
def load_retriever(llm, db):
|
152 |
-
qa_retriever = RetrievalQA.from_chain_type(llm=llm, chain_type="stuff",
|
153 |
-
retriever=db.as_retriever(),
|
154 |
-
chain_type_kwargs= chain_type_kwargs)
|
155 |
-
|
156 |
-
return qa_retriever
|
157 |
-
|
158 |
-
def retrieve_document(query_input):
|
159 |
-
related_doc = vector_database.similarity_search(query_input)
|
160 |
-
return related_doc
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
def retrieve_answer():
|
165 |
-
prompt_answer= st.session_state.my_text_input
|
166 |
-
answer = qa_retriever.run(prompt_answer)
|
167 |
-
log = {"timestamp": datetime.datetime.now(),
|
168 |
-
"question":st.session_state.my_text_input,
|
169 |
-
"generated_answer": answer[6:],
|
170 |
-
"rating":0 }
|
171 |
-
|
172 |
-
st.session_state.history.append(log)
|
173 |
-
# update_worksheet_qa()
|
174 |
-
st.session_state.chat_history.append({"message": st.session_state.my_text_input, "is_user": True})
|
175 |
-
st.session_state.chat_history.append({"message": answer[6:] , "is_user": False})
|
176 |
-
|
177 |
-
st.session_state.my_text_input = ""
|
178 |
-
|
179 |
-
return answer[6:] #this positional slicing helps remove "<pad> " at the beginning
|
180 |
-
|
181 |
-
|
182 |
-
def new_retrieve_answer():
|
183 |
-
prompt_answer= st.session_state.my_text_input + ". Try to be elaborate and informative in your answer."
|
184 |
-
answer = conversational_qa_memory_retriever({"question": prompt_answer, })
|
185 |
-
log = {"timestamp": datetime.datetime.now(),
|
186 |
-
"question":st.session_state.my_text_input,
|
187 |
-
"generated_answer": answer['answer'][6:],
|
188 |
-
"rating":0 }
|
189 |
-
|
190 |
-
print(f"condensed quesion : {question_generator.run({'chat_history': answer['chat_history'], 'question' : prompt_answer})}")
|
191 |
-
|
192 |
-
print(answer["chat_history"])
|
193 |
-
st.session_state.history.append(log)
|
194 |
-
# update_worksheet_qa()
|
195 |
-
st.session_state.chat_history.append({"message": st.session_state.my_text_input, "is_user": True})
|
196 |
-
st.session_state.chat_history.append({"message": answer['answer'][6:] , "is_user": False})
|
197 |
-
|
198 |
-
st.session_state.my_text_input = ""
|
199 |
-
|
200 |
-
return answer['answer'][6:] #this positional slicing helps remove "<pad> " at the beginning
|
201 |
-
|
202 |
-
# def update_score():
|
203 |
-
# st.session_state.session_rating = st.session_state.rating
|
204 |
-
|
205 |
-
|
206 |
-
def update_worksheet_qa():
|
207 |
-
# st.session_state.session_rating = st.session_state.rating
|
208 |
-
#This if helps validate the initiated rating, if 0, then the google sheet would not be updated
|
209 |
-
#(edited) now even with the score of 0, we still want to store the log because some users do not give the score to complete the logging
|
210 |
-
# if st.session_state.session_rating == 0:
|
211 |
-
worksheet_qa.append_row([st.session_state.history[-1]['timestamp'].strftime(datetime_format),
|
212 |
-
st.session_state.history[-1]['question'],
|
213 |
-
st.session_state.history[-1]['generated_answer'],
|
214 |
-
0])
|
215 |
-
# else:
|
216 |
-
# worksheet_qa.append_row([st.session_state.history[-1]['timestamp'].strftime(datetime_format),
|
217 |
-
# st.session_state.history[-1]['question'],
|
218 |
-
# st.session_state.history[-1]['generated_answer'],
|
219 |
-
# st.session_state.session_rating
|
220 |
-
# ])
|
221 |
-
|
222 |
-
def update_worksheet_comment():
|
223 |
-
worksheet_comment.append_row([datetime.datetime.now().strftime(datetime_format),
|
224 |
-
feedback_input])
|
225 |
-
success_message = st.success('Feedback successfully submitted, thank you', icon="✅",
|
226 |
-
)
|
227 |
-
time.sleep(3)
|
228 |
-
success_message.empty()
|
229 |
-
|
230 |
-
|
231 |
-
def clean_chat_history():
|
232 |
-
st.session_state.chat_history = []
|
233 |
-
conversational_qa_memory_retriever.memory.chat_memory.clear() #add this to remove
|
234 |
-
|
235 |
-
#--------------
|
236 |
-
|
237 |
-
|
238 |
-
if "history" not in st.session_state: #this one is for the google sheet logging
|
239 |
-
st.session_state.history = []
|
240 |
-
|
241 |
-
|
242 |
-
if "chat_history" not in st.session_state: #this one is to pass previous messages into chat flow
|
243 |
-
st.session_state.chat_history = []
|
244 |
-
# if "session_rating" not in st.session_state:
|
245 |
-
# st.session_state.session_rating = 0
|
246 |
-
|
247 |
-
|
248 |
-
# credentials= json.loads(st.secrets['google_sheet_credential'])
|
249 |
-
|
250 |
-
# service_account = gspread.service_account_from_dict(credentials)
|
251 |
-
# workbook= service_account.open("aitGPT-qa-log")
|
252 |
-
# worksheet_qa = workbook.worksheet("Sheet1")
|
253 |
-
# worksheet_comment = workbook.worksheet("Sheet2")
|
254 |
-
# datetime_format= "%Y-%m-%d %H:%M:%S"
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
load_scraped_web_info()
|
259 |
-
embedding_model = load_embedding_model()
|
260 |
-
vector_database = load_faiss_index()
|
261 |
-
llm_model = load_llm_model()
|
262 |
-
qa_retriever = load_retriever(llm= llm_model, db= vector_database)
|
263 |
-
conversational_qa_memory_retriever, question_generator = load_conversational_qa_memory_retriever()
|
264 |
-
print("all load done")
|
265 |
-
|
266 |
-
|
267 |
-
# Try adding this to set to clear the memory in each session
|
268 |
-
if st.session_state.chat_history == []:
|
269 |
-
conversational_qa_memory_retriever.memory.chat_memory.clear()
|
270 |
-
#Addional things for Conversation flows
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
st.write("# aitGPT 🤖 ")
|
278 |
-
st.markdown("""
|
279 |
-
#### The aitGPT project is a virtual assistant developed by the :green[Asian Institute of Technology] that contains a vast amount of information gathered from 205 AIT-related websites.
|
280 |
-
The goal of this chatbot is to provide an alternative way for applicants and current students to access information about the institute, including admission procedures, campus facilities, and more.
|
281 |
-
""")
|
282 |
-
st.write(' ⚠️ Please expect to wait **~ 10 - 20 seconds per question** as thi app is running on CPU against 3-billion-parameter LLM')
|
283 |
-
|
284 |
-
st.markdown("---")
|
285 |
-
st.write(" ")
|
286 |
-
st.write("""
|
287 |
-
### ❔ Ask a question
|
288 |
-
""")
|
289 |
-
|
290 |
-
|
291 |
-
for chat in st.session_state.chat_history:
|
292 |
-
st_message(**chat)
|
293 |
-
|
294 |
-
query_input = st.text_input(label= 'What would you like to know about AIT?' , key = 'my_text_input', on_change= new_retrieve_answer )
|
295 |
-
# generate_button = st.button(label = 'Ask question!')
|
296 |
-
|
297 |
-
# if generate_button:
|
298 |
-
# answer = retrieve_answer(query_input)
|
299 |
-
# log = {"timestamp": datetime.datetime.now(),
|
300 |
-
# "question":query_input,
|
301 |
-
# "generated_answer": answer,
|
302 |
-
# "rating":0 }
|
303 |
-
|
304 |
-
# st.session_state.history.append(log)
|
305 |
-
# update_worksheet_qa()
|
306 |
-
# st.session_state.chat_history.append({"message": query_input, "is_user": True})
|
307 |
-
# st.session_state.chat_history.append({"message": answer, "is_user": False})
|
308 |
-
|
309 |
-
# print(st.session_state.chat_history)
|
310 |
-
|
311 |
-
|
312 |
-
clear_button = st.button("Start new convo",
|
313 |
-
on_click=clean_chat_history)
|
314 |
-
|
315 |
-
|
316 |
-
st.write(" ")
|
317 |
-
st.write(" ")
|
318 |
-
|
319 |
-
st.markdown("---")
|
320 |
-
st.write("""
|
321 |
-
### 💌 Your voice matters
|
322 |
-
""")
|
323 |
-
|
324 |
-
feedback_input = st.text_area(label= 'please leave your feedback or any ideas to make this bot more knowledgeable and fun')
|
325 |
-
feedback_button = st.button(label = 'Submit feedback!')
|
326 |
-
|
327 |
-
if feedback_button:
|
328 |
-
update_worksheet_comment()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CikeyQI/meme-api/meme_generator/memes/acg_entrance/__init__.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
from pathlib import Path
|
2 |
-
from typing import List
|
3 |
-
|
4 |
-
from pil_utils import BuildImage
|
5 |
-
|
6 |
-
from meme_generator import add_meme
|
7 |
-
from meme_generator.exception import TextOverLength
|
8 |
-
from meme_generator.utils import make_jpg_or_gif
|
9 |
-
|
10 |
-
img_dir = Path(__file__).parent / "images"
|
11 |
-
|
12 |
-
|
13 |
-
def acg_entrance(images: List[BuildImage], texts: List[str], args):
|
14 |
-
text = texts[0] if texts else "走,跟我去二次元吧"
|
15 |
-
frame = BuildImage.open(img_dir / "0.png")
|
16 |
-
try:
|
17 |
-
frame.draw_text(
|
18 |
-
(30, 720, frame.width - 30, 810),
|
19 |
-
text,
|
20 |
-
max_fontsize=50,
|
21 |
-
min_fontsize=25,
|
22 |
-
fill="white",
|
23 |
-
)
|
24 |
-
except ValueError:
|
25 |
-
raise TextOverLength(text)
|
26 |
-
|
27 |
-
def make(img: BuildImage) -> BuildImage:
|
28 |
-
img = img.convert("RGBA").resize((290, 410), keep_ratio=True)
|
29 |
-
return frame.copy().paste(img, (190, 265), below=True)
|
30 |
-
|
31 |
-
return make_jpg_or_gif(images[0], make)
|
32 |
-
|
33 |
-
|
34 |
-
add_meme(
|
35 |
-
"acg_entrance",
|
36 |
-
acg_entrance,
|
37 |
-
min_images=1,
|
38 |
-
max_images=1,
|
39 |
-
min_texts=0,
|
40 |
-
max_texts=1,
|
41 |
-
default_texts=["走,跟我去二次元吧"],
|
42 |
-
keywords=["二次元入口"],
|
43 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spaces/CofAI/chat.v2/README.md
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
---
|
2 |
-
title: BETA.Chat.CofAI
|
3 |
-
emoji: 🗨☕💬
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: green
|
6 |
-
sdk: docker
|
7 |
-
pinned: false
|
8 |
-
duplicated_from: CofAI/chat.cofai
|
9 |
-
---
|
10 |
-
|
11 |
-
✋ Приложение защищено авторским правом, копирование запрещено, но вы можете встроить это пространство!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|